Issue 505
[zxing.git] / cpp / core / src / zxing / qrcode / detector / AlignmentPatternFinder.cpp
index bc4aaac..1f76491 100644 (file)
@@ -37,7 +37,7 @@ float AlignmentPatternFinder::centerFromEnd(vector<int> &stateCount, int end) {
 bool AlignmentPatternFinder::foundPatternCross(vector<int> &stateCount) {
   float maxVariance = moduleSize_ / 2.0f;
   for (size_t i = 0; i < 3; i++) {
-    if (labs(moduleSize_ - stateCount[i]) >= maxVariance) {
+    if (abs(moduleSize_ - stateCount[i]) >= maxVariance) {
       return false;
     }
   }
@@ -86,7 +86,7 @@ float AlignmentPatternFinder::crossCheckVertical(size_t startI, size_t centerJ,
   }
 
   int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
-  if (5 * labs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
+  if (5 * abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
     return NAN;
   }
 
@@ -112,15 +112,19 @@ Ref<AlignmentPattern> AlignmentPatternFinder::handlePossibleCenter(vector<int> &
     // 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,
-    size_t height, float moduleSize) :
+                                               size_t height, float moduleSize, 
+                                               Ref<ResultPointCallback>const& callback) :
     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() {