Issue 505
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 12 Aug 2010 20:51:09 +0000 (20:51 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 12 Aug 2010 20:51:09 +0000 (20:51 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1524 59b500cc-1b3d-0410-9834-0bbf25fbcc57

12 files changed:
cpp/core/src/zxing/DecodeHints.cpp
cpp/core/src/zxing/DecodeHints.h
cpp/core/src/zxing/ResultPoint.cpp
cpp/core/src/zxing/ResultPoint.h
cpp/core/src/zxing/ResultPointCallback.cpp [new file with mode: 0644]
cpp/core/src/zxing/ResultPointCallback.h [new file with mode: 0644]
cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.cpp
cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h
cpp/core/src/zxing/qrcode/detector/Detector.cpp
cpp/core/src/zxing/qrcode/detector/Detector.h
cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp
cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h

index 6947de5..8209f76 100644 (file)
@@ -100,4 +100,12 @@ bool DecodeHints::getTryHarder() const {
   return (hints & TRYHARDER_HINT);
 }
 
   return (hints & TRYHARDER_HINT);
 }
 
+void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const& _callback) {
+    callback = _callback;
+}
+
+Ref<ResultPointCallback> DecodeHints::getResultPointCallback() const {
+    return callback;
+}
+
 } /* namespace */
 } /* namespace */
index 897939d..f5c27f5 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <zxing/BarcodeFormat.h>
  */
 
 #include <zxing/BarcodeFormat.h>
+#include <zxing/ResultPointCallback.h>
 
 namespace zxing {
 
 
 namespace zxing {
 
@@ -42,6 +43,8 @@ class DecodeHints {
 
   DecodeHintType hints;
 
 
   DecodeHintType hints;
 
+  Ref<ResultPointCallback> callback;
+
  public:
 
   static const DecodeHints PRODUCT_HINT;
  public:
 
   static const DecodeHints PRODUCT_HINT;
@@ -56,6 +59,9 @@ class DecodeHints {
   void setTryHarder(bool toset);
   bool getTryHarder() const;
 
   void setTryHarder(bool toset);
   bool getTryHarder() const;
 
+  void setResultPointCallback(Ref<ResultPointCallback> const&);
+  Ref<ResultPointCallback> getResultPointCallback() const;
+
 };
 
 }
 };
 
 }
index 4649568..9670685 100755 (executable)
@@ -20,3 +20,8 @@
 
 #include <zxing/ResultPoint.h>
 
 
 #include <zxing/ResultPoint.h>
 
+namespace zxing {
+
+ResultPoint::~ResultPoint() {}
+
+}
index 4ad24e2..f3e6090 100644 (file)
@@ -28,6 +28,8 @@ class ResultPoint : public Counted {
 protected:
   ResultPoint() {}
 public:
 protected:
   ResultPoint() {}
 public:
+  virtual ~ResultPoint();
+
   virtual float getX() const = 0;
   virtual float getY() const = 0;
 };
   virtual float getX() const = 0;
   virtual float getY() const = 0;
 };
diff --git a/cpp/core/src/zxing/ResultPointCallback.cpp b/cpp/core/src/zxing/ResultPointCallback.cpp
new file mode 100644 (file)
index 0000000..72474c9
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ *  ResultPointCallback.cpp
+ *  zxing
+ *
+ *  Created by Christian Brunschen on 13/05/2008.
+ *  Copyright 2008 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/ResultPointCallback.h>
+
+namespace zxing {
+
+ResultPointCallback::~ResultPointCallback() {}
+
+}
diff --git a/cpp/core/src/zxing/ResultPointCallback.h b/cpp/core/src/zxing/ResultPointCallback.h
new file mode 100644 (file)
index 0000000..2687656
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __RESULT_POINT_CALLBACK_H__
+#define __RESULT_POINT_CALLBACK_H__
+
+/*
+ *  ResultPointCallback.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class ResultPoint;
+
+class ResultPointCallback : public Counted {
+protected:
+  ResultPointCallback() {}
+public:
+  virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
+  virtual ~ResultPointCallback();
+};
+
+}
+
+#endif // __RESULT_POINT_CALLBACK_H__
index 017e2ee..1f76491 100644 (file)
@@ -112,15 +112,19 @@ Ref<AlignmentPattern> AlignmentPatternFinder::handlePossibleCenter(vector<int> &
     // Hadn't found this before; save it
     tmp->retain();
     possibleCenters_->push_back(tmp);
     // Hadn't found this before; save it
     tmp->retain();
     possibleCenters_->push_back(tmp);
+    if (callback_ != 0) {
+      callback_->foundPossibleResultPoint(*tmp);
+    }
   }
   Ref<AlignmentPattern> result;
   return result;
 }
 
 AlignmentPatternFinder::AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width,
   }
   Ref<AlignmentPattern> result;
   return result;
 }
 
 AlignmentPatternFinder::AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width,
-    size_t height, float moduleSize) :
+                                               size_t height, float moduleSize, 
+                                               Ref<ResultPointCallback>const& callback) :
     image_(image), possibleCenters_(new vector<AlignmentPattern *> ()), startX_(startX), startY_(startY),
     image_(image), possibleCenters_(new vector<AlignmentPattern *> ()), startX_(startX), startY_(startY),
-    width_(width), height_(height), moduleSize_(moduleSize) {
+    width_(width), height_(height), moduleSize_(moduleSize), callback_(callback) {
 }
 
 AlignmentPatternFinder::~AlignmentPatternFinder() {
 }
 
 AlignmentPatternFinder::~AlignmentPatternFinder() {
index bfcf148..dbc7b0a 100644 (file)
@@ -23,6 +23,7 @@
 #include "AlignmentPattern.h"
 #include <zxing/common/Counted.h>
 #include <zxing/common/BitMatrix.h>
 #include "AlignmentPattern.h"
 #include <zxing/common/Counted.h>
 #include <zxing/common/BitMatrix.h>
+#include <zxing/ResultPointCallback.h>
 #include <vector>
 
 namespace zxing {
 #include <vector>
 
 namespace zxing {
@@ -51,7 +52,7 @@ private:
 
 public:
   AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width, size_t height,
 
 public:
   AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width, size_t height,
-                         float moduleSize);
+                         float moduleSize, Ref<ResultPointCallback>const& callback);
   ~AlignmentPatternFinder();
   Ref<AlignmentPattern> find();
   
   ~AlignmentPatternFinder();
   Ref<AlignmentPattern> find();
   
@@ -59,6 +60,7 @@ private:
   AlignmentPatternFinder(const AlignmentPatternFinder&);
   AlignmentPatternFinder& operator =(const AlignmentPatternFinder&);
   
   AlignmentPatternFinder(const AlignmentPatternFinder&);
   AlignmentPatternFinder& operator =(const AlignmentPatternFinder&);
   
+  Ref<ResultPointCallback> callback_;
 };
 }
 }
 };
 }
 }
index eef3095..bba077f 100644 (file)
@@ -44,7 +44,8 @@ Ref<BitMatrix> Detector::getImage() {
 }\r
 \r
 Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {\r
 }\r
 \r
 Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {\r
-  FinderPatternFinder finder(image_);\r
+  callback_ = hints.getResultPointCallback();\r
+  FinderPatternFinder finder(image_, hints.getResultPointCallback());\r
   Ref<FinderPatternInfo> info(finder.find(hints));\r
 \r
   Ref<FinderPattern> topLeft(info->getTopLeft());\r
   Ref<FinderPatternInfo> info(finder.find(hints));\r
 \r
   Ref<FinderPattern> topLeft(info->getTopLeft());\r
@@ -271,7 +272,7 @@ Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize
   int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);\r
 \r
   AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX\r
   int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);\r
 \r
   AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX\r
-                                         - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize);\r
+                                         - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);\r
   return alignmentFinder.find();\r
 }\r
 \r
   return alignmentFinder.find();\r
 }\r
 \r
index e63aac1..6ec3052 100644 (file)
@@ -25,6 +25,7 @@
 #include <zxing/common/BitMatrix.h>\r
 #include <zxing/qrcode/detector/AlignmentPattern.h>\r
 #include <zxing/common/PerspectiveTransform.h>\r
 #include <zxing/common/BitMatrix.h>\r
 #include <zxing/qrcode/detector/AlignmentPattern.h>\r
 #include <zxing/common/PerspectiveTransform.h>\r
+#include <zxing/ResultPointCallback.h>\r
 \r
 namespace zxing {\r
 \r
 \r
 namespace zxing {\r
 \r
@@ -35,6 +36,7 @@ namespace qrcode {
 class Detector : public Counted {\r
 private:\r
   Ref<BitMatrix> image_;\r
 class Detector : public Counted {\r
 private:\r
   Ref<BitMatrix> image_;\r
+  Ref<ResultPointCallback> callback_;\r
 \r
 protected:\r
   Ref<BitMatrix> getImage();\r
 \r
 protected:\r
   Ref<BitMatrix> getImage();\r
index fa02af3..52cd1cc 100644 (file)
@@ -236,6 +236,9 @@ bool FinderPatternFinder::handlePossibleCenter(int* stateCount, size_t i, size_t
       if (!found) {
         Ref<FinderPattern> newPattern(new FinderPattern(centerJ, centerI, estimatedModuleSize));
         possibleCenters_.push_back(newPattern);
       if (!found) {
         Ref<FinderPattern> newPattern(new FinderPattern(centerJ, centerI, estimatedModuleSize));
         possibleCenters_.push_back(newPattern);
+        if (callback_ != 0) {
+          callback_->foundPossibleResultPoint(*newPattern);
+        }
       }
       return true;
     }
       }
       return true;
     }
@@ -384,8 +387,9 @@ float FinderPatternFinder::distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2) {
   return (float)sqrt(dx * dx + dy * dy);
 }
 
   return (float)sqrt(dx * dx + dy * dy);
 }
 
-FinderPatternFinder::FinderPatternFinder(Ref<BitMatrix> image) :
-    image_(image), possibleCenters_(), hasSkipped_(false) {
+FinderPatternFinder::FinderPatternFinder(Ref<BitMatrix> image,
+                                           Ref<ResultPointCallback>const& callback) :
+    image_(image), possibleCenters_(), hasSkipped_(false), callback_(callback) {
 }
 
 Ref<FinderPatternInfo> FinderPatternFinder::find(DecodeHints const& hints) {
 }
 
 Ref<FinderPatternInfo> FinderPatternFinder::find(DecodeHints const& hints) {
index ac8489e..6c8684d 100644 (file)
@@ -24,6 +24,7 @@
 #include <zxing/qrcode/detector/FinderPatternInfo.h>
 #include <zxing/common/Counted.h>
 #include <zxing/common/BitMatrix.h>
 #include <zxing/qrcode/detector/FinderPatternInfo.h>
 #include <zxing/common/Counted.h>
 #include <zxing/common/BitMatrix.h>
+#include <zxing/ResultPointCallback.h>
 #include <vector>
 
 namespace zxing {
 #include <vector>
 
 namespace zxing {
@@ -42,6 +43,8 @@ private:
   std::vector<Ref<FinderPattern> > possibleCenters_;
   bool hasSkipped_;
 
   std::vector<Ref<FinderPattern> > possibleCenters_;
   bool hasSkipped_;
 
+  Ref<ResultPointCallback> callback_;
+
   /** stateCount must be int[5] */
   static float centerFromEnd(int* stateCount, int end);
   static bool foundPatternCross(int* stateCount);
   /** stateCount must be int[5] */
   static float centerFromEnd(int* stateCount, int end);
   static bool foundPatternCross(int* stateCount);
@@ -55,10 +58,9 @@ private:
   bool haveMultiplyConfirmedCenters();
   std::vector<Ref<FinderPattern> > selectBestPatterns();
   static std::vector<Ref<FinderPattern> > orderBestPatterns(std::vector<Ref<FinderPattern> > patterns);
   bool haveMultiplyConfirmedCenters();
   std::vector<Ref<FinderPattern> > selectBestPatterns();
   static std::vector<Ref<FinderPattern> > orderBestPatterns(std::vector<Ref<FinderPattern> > patterns);
-
 public:
   static float distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2);
 public:
   static float distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2);
-  FinderPatternFinder(Ref<BitMatrix> image);
+  FinderPatternFinder(Ref<BitMatrix> image, Ref<ResultPointCallback>const&);
   Ref<FinderPatternInfo> find(DecodeHints const& hints);
 };
 }
   Ref<FinderPatternInfo> find(DecodeHints const& hints);
 };
 }