From 88a46d0773cbdc4b9008ffd43afc147c372b6bad Mon Sep 17 00:00:00 2001 From: "smparkes@smparkes.net" Date: Sun, 8 Jul 2012 17:28:20 +0000 Subject: [PATCH] c++ version of r2344 git-svn-id: https://zxing.googlecode.com/svn/trunk@2346 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- cpp/core/src/zxing/Binarizer.cpp | 8 ++++++++ cpp/core/src/zxing/Binarizer.h | 4 ++++ cpp/core/src/zxing/qrcode/detector/Detector.cpp | 6 +++++- cpp/core/src/zxing/qrcode/detector/Detector.h | 9 ++++++--- cpp/core/src/zxing/qrcode/detector/FinderPattern.h | 3 ++- .../src/zxing/qrcode/detector/FinderPatternFinder.cpp | 9 +++++++++ cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h | 5 +++++ 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/cpp/core/src/zxing/Binarizer.cpp b/cpp/core/src/zxing/Binarizer.cpp index 86d891558..954b74073 100644 --- a/cpp/core/src/zxing/Binarizer.cpp +++ b/cpp/core/src/zxing/Binarizer.cpp @@ -33,5 +33,13 @@ namespace zxing { Ref Binarizer::getLuminanceSource() const { return source_; } + + int Binarizer::getWidth() const { + return source_->getWidth(); + } + + int Binarizer::getHeight() const { + return source_->getHeight(); + } } diff --git a/cpp/core/src/zxing/Binarizer.h b/cpp/core/src/zxing/Binarizer.h index 8ae258d7f..238c12ace 100644 --- a/cpp/core/src/zxing/Binarizer.h +++ b/cpp/core/src/zxing/Binarizer.h @@ -40,6 +40,10 @@ class Binarizer : public Counted { Ref getLuminanceSource() const ; virtual Ref createBinarizer(Ref source) = 0; + + int getWidth() const; + int getHeight() const; + }; } diff --git a/cpp/core/src/zxing/qrcode/detector/Detector.cpp b/cpp/core/src/zxing/qrcode/detector/Detector.cpp index 53c9403c7..e872c3a05 100644 --- a/cpp/core/src/zxing/qrcode/detector/Detector.cpp +++ b/cpp/core/src/zxing/qrcode/detector/Detector.cpp @@ -42,10 +42,14 @@ Detector::Detector(Ref image) : image_(image) { } -Ref Detector::getImage() { +Ref Detector::getImage() const { return image_; } +Ref Detector::getResultPointCallback() const { + return callback_; +} + Ref Detector::detect(DecodeHints const& hints) { callback_ = hints.getResultPointCallback(); FinderPatternFinder finder(image_, hints.getResultPointCallback()); diff --git a/cpp/core/src/zxing/qrcode/detector/Detector.h b/cpp/core/src/zxing/qrcode/detector/Detector.h index 62e5c8642..383d5c250 100644 --- a/cpp/core/src/zxing/qrcode/detector/Detector.h +++ b/cpp/core/src/zxing/qrcode/detector/Detector.h @@ -1,3 +1,4 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __DETECTOR_H__ #define __DETECTOR_H__ @@ -40,7 +41,8 @@ private: Ref callback_; protected: - Ref getImage(); + Ref getImage() const; + Ref getResultPointCallback() const; static Ref sampleGrid(Ref image, int dimension, Ref); static int computeDimension(Ref topLeft, Ref topRight, Ref bottomLeft, @@ -53,14 +55,15 @@ protected: float allowanceFactor); Ref processFinderPatternInfo(Ref info); public: - virtual Ref createTransform(Ref topLeft, Ref topRight, Ref < ResultPoint > bottomLeft, Ref alignmentPattern, int dimension); Detector(Ref image); Ref detect(DecodeHints const& hints); + + }; } } -#endif // __DETECTOR_H__ \ No newline at end of file +#endif // __DETECTOR_H__ diff --git a/cpp/core/src/zxing/qrcode/detector/FinderPattern.h b/cpp/core/src/zxing/qrcode/detector/FinderPattern.h index e23ba5dc0..87b61c8ae 100644 --- a/cpp/core/src/zxing/qrcode/detector/FinderPattern.h +++ b/cpp/core/src/zxing/qrcode/detector/FinderPattern.h @@ -32,9 +32,10 @@ namespace zxing { float estimatedModuleSize_; int count_; + FinderPattern(float posX, float posY, float estimatedModuleSize, int count); + public: FinderPattern(float posX, float posY, float estimatedModuleSize); - FinderPattern(float posX, float posY, float estimatedModuleSize, int count); int getCount() const; float getEstimatedModuleSize() const; void incrementCount(); diff --git a/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp b/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp index 35ce976b5..a363df4d7 100644 --- a/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp +++ b/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp @@ -537,5 +537,14 @@ Ref FinderPatternFinder::find(DecodeHints const& hints) { Ref result(new FinderPatternInfo(patternInfo)); return result; } + +Ref FinderPatternFinder::getImage() { + return image_; +} + +std::vector >& FinderPatternFinder::getPossibleCenters() { + return possibleCenters_; +} + } } diff --git a/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h b/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h index 1d85f9b65..82d43652f 100644 --- a/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h +++ b/cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h @@ -1,3 +1,4 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __FINDER_PATTERN_FINDER_H__ #define __FINDER_PATTERN_FINDER_H__ @@ -60,6 +61,10 @@ protected: bool haveMultiplyConfirmedCenters(); std::vector > selectBestPatterns(); static std::vector > orderBestPatterns(std::vector > patterns); + + Ref getImage(); + std::vector >& getPossibleCenters(); + public: static float distance(Ref p1, Ref p2); FinderPatternFinder(Ref image, Refconst&);