X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=cpp%2Fcore%2Fsrc%2Fzxing%2Fqrcode%2Fdetector%2FDetector.cpp;h=bba077f9da552c18f4e089d5be6aedf3cdd9d439;hp=6c325586ec902a31fbc23471389a87a267a98108;hb=d59aa5593ed5a911b1141be85d1888088c21e859;hpb=985fc411759edc0a9996067d8ee9c55976614200 diff --git a/cpp/core/src/zxing/qrcode/detector/Detector.cpp b/cpp/core/src/zxing/qrcode/detector/Detector.cpp index 6c325586..bba077f9 100644 --- a/cpp/core/src/zxing/qrcode/detector/Detector.cpp +++ b/cpp/core/src/zxing/qrcode/detector/Detector.cpp @@ -44,7 +44,8 @@ Ref Detector::getImage() { } Ref Detector::detect(DecodeHints const& hints) { - FinderPatternFinder finder(image_); + callback_ = hints.getResultPointCallback(); + FinderPatternFinder finder(image_, hints.getResultPointCallback()); Ref info(finder.find(hints)); Ref topLeft(info->getTopLeft()); @@ -185,9 +186,9 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, if (otherToX < 0) { scale = (float) fromX / (float) (fromX - otherToX); otherToX = 0; - } else if (otherToX >= (int)image_->getWidth()) { - scale = (float) (image_->getWidth() - 1 - fromX) / (float) (otherToX - fromX); - otherToX = image_->getWidth() - 1; + } else if (otherToX > (int)image_->getWidth()) { + scale = (float) (image_->getWidth() - fromX) / (float) (otherToX - fromX); + otherToX = image_->getWidth(); } int otherToY = (int) (fromY - (toY - fromY) * scale); @@ -195,14 +196,14 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, if (otherToY < 0) { scale = (float) fromY / (float) (fromY - otherToY); otherToY = 0; - } else if (otherToY >= (int)image_->getHeight()) { - scale = (float) (image_->getHeight() - 1 - fromY) / (float) (otherToY - fromY); - otherToY = image_->getHeight() - 1; + } else if (otherToY > (int)image_->getHeight()) { + scale = (float) (image_->getHeight() - fromY) / (float) (otherToY - fromY); + otherToY = image_->getHeight(); } otherToX = (int) (fromX + (otherToX - fromX) * scale); result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); - return result - 1.0f; // -1 because we counted the middle pixel twice + return result; } float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) { @@ -241,6 +242,9 @@ float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) if (state == 3) { // Found black, white, black, and stumbled back onto white; done int diffX = x - fromX; int diffY = y - fromY; + if (xstep < 0) { + diffX++; + } return (float)sqrt((double)(diffX * diffX + diffY * diffY)); } error += dy; @@ -268,7 +272,7 @@ Ref Detector::findAlignmentInRegion(float overallEstModuleSize int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance); AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize); + - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_); return alignmentFinder.find(); }