示例#1
0
Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,
    float allowanceFactor) {
  // Look for an alignment pattern (3 modules in size) around where it
  // should be
  int allowance = (int)(allowanceFactor * overallEstModuleSize);
  int alignmentAreaLeftX = max(0, estAlignmentX - allowance);
  int alignmentAreaRightX = min((int)(image_->getWidth() - 1), estAlignmentX + allowance);
  if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
      throw zxing::ReaderException("region too small to hold alignment pattern");
  }
  int alignmentAreaTopY = max(0, estAlignmentY - allowance);
  int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);
  if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
      throw zxing::ReaderException("region too small to hold alignment pattern");
  }

  AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX
                                         - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);
  return alignmentFinder.find();
}
示例#2
0
 Ref<AlignmentPattern>
 Detector::findAlignmentInRegion(float overallEstModuleSize,
                                 int estAlignmentX,
                                 int estAlignmentY,
                                 float allowanceFactor) {
   // Look for an alignment pattern (3 modules in size) around where it
   // should be
   int allowance = (int) (allowanceFactor * overallEstModuleSize);
   int alignmentAreaLeftX = max(0, estAlignmentX - allowance);
   int alignmentAreaRightX = min((int) (image_->getWidth() - 1),
                                 estAlignmentX + allowance);
   int alignmentAreaTopY = max(0, estAlignmentY - allowance);
   int alignmentAreaBottomY = min((int) (image_->getHeight() - 1), 
                                  estAlignmentY + allowance);
   
   AlignmentPatternFinder
   alignmentFinder(image_,
                   alignmentAreaLeftX,
                   alignmentAreaTopY,
                   alignmentAreaRightX - alignmentAreaLeftX,
                   alignmentAreaBottomY - alignmentAreaTopY,
                   overallEstModuleSize);
   return alignmentFinder.find();
 }