findAlignmentInRegion method
Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. This method uses [AlignmentPattern].
@param overallEstModuleSize estimated module size so far @param estAlignmentX x coordinate of center of area probably containing alignment pattern @param estAlignmentY y coordinate of above @param allowanceFactor number of pixels in all directions to search from the center @return AlignmentPattern if found, or null otherwise @throws NotFoundException if an unexpected error occurs during detection
Implementation
//@protected
AlignmentPattern findAlignmentInRegion(
double overallEstModuleSize,
int estAlignmentX,
int estAlignmentY,
double allowanceFactor,
) {
// Look for an alignment pattern (3 modules in size) around where it
// should be
final allowance = (allowanceFactor * overallEstModuleSize).toInt();
final alignmentAreaLeftX = math.max(0, estAlignmentX - allowance);
final alignmentAreaRightX =
math.min(_image.width - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
throw NotFoundException.instance;
}
final alignmentAreaTopY = math.max(0, estAlignmentY - allowance);
final alignmentAreaBottomY =
math.min(_image.height - 1, estAlignmentY + allowance);
if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
throw NotFoundException.instance;
}
final alignmentFinder = AlignmentPatternFinder(
_image,
alignmentAreaLeftX,
alignmentAreaTopY,
alignmentAreaRightX - alignmentAreaLeftX,
alignmentAreaBottomY - alignmentAreaTopY,
overallEstModuleSize,
_resultPointCallback,
);
return alignmentFinder.find();
}