}\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
if (otherToX < 0) {\r
scale = (float) fromX / (float) (fromX - otherToX);\r
otherToX = 0;\r
- } else if (otherToX >= (int)image_->getWidth()) {\r
- scale = (float) (image_->getWidth() - 1 - fromX) / (float) (otherToX - fromX);\r
- otherToX = image_->getWidth() - 1;\r
+ } else if (otherToX > (int)image_->getWidth()) {\r
+ scale = (float) (image_->getWidth() - fromX) / (float) (otherToX - fromX);\r
+ otherToX = image_->getWidth();\r
}\r
int otherToY = (int) (fromY - (toY - fromY) * scale);\r
\r
if (otherToY < 0) {\r
scale = (float) fromY / (float) (fromY - otherToY);\r
otherToY = 0;\r
- } else if (otherToY >= (int)image_->getHeight()) {\r
- scale = (float) (image_->getHeight() - 1 - fromY) / (float) (otherToY - fromY);\r
- otherToY = image_->getHeight() - 1;\r
+ } else if (otherToY > (int)image_->getHeight()) {\r
+ scale = (float) (image_->getHeight() - fromY) / (float) (otherToY - fromY);\r
+ otherToY = image_->getHeight();\r
}\r
otherToX = (int) (fromX + (otherToX - fromX) * scale);\r
\r
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);\r
- return result - 1.0f; // -1 because we counted the middle pixel twice\r
+ return result;\r
}\r
\r
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {\r
if (state == 3) { // Found black, white, black, and stumbled back onto white; done\r
int diffX = x - fromX;\r
int diffY = y - fromY;\r
+ if (xstep < 0) {\r
+ diffX++;\r
+ }\r
return (float)sqrt((double)(diffX * diffX + diffY * diffY));\r
}\r
error += dy;\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