@Override public int compare(FinderPattern center1, FinderPattern center2) { float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; } }
/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average * based on count. */ FinderPattern combineEstimate(float i, float j, float newModuleSize) { int combinedCount = count + 1; float combinedX = (count * getX() + j) / combinedCount; float combinedY = (count * getY() + i) / combinedCount; float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount; return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); }
/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. */ AlignmentPattern combineEstimate(float i, float j, float newModuleSize) { float combinedX = (getX() + j) / 2.0f; float combinedY = (getY() + i) / 2.0f; float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); }
/** * <p>Detects a QR Code in an image.</p> * * @param hints optional hints to detector * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ public final DetectorResult detect(Map<DecodeHintType,?> hints) throws NotFoundException, FormatException { resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback); FinderPatternInfo info = finder.find(hints); return processFinderPatternInfo(info); }
/** * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated * position and size -- meaning, it is at nearly the same center with nearly the same size.</p> */ boolean aboutEquals(float moduleSize, float i, float j) { if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; } return false; }
/** * <p>Determines if this finder pattern "about equals" a finder pattern at the stated * position and size -- meaning, it is at nearly the same center with nearly the same size.</p> */ boolean aboutEquals(float moduleSize, float i, float j) { if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; } return false; }
/** * <p>Detects a QR Code in an image.</p> * * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ public DetectorResult detect() throws NotFoundException, FormatException { return detect(null); }
/** * <p>Computes an average estimated module size based on estimated derived from the positions * of the three finder patterns.</p> */ protected float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft) { // Take the average return (calculateModuleSizeOneWay(topLeft, topRight) + calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; }
/** * <p>Detects a QR Code in an image.</p> * * @param hints optional hints to detector * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ public final DetectorResult detect(Map<DecodeHintType,?> hints) throws NotFoundException, FormatException { resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback); FinderPatternInfo info = finder.find(hints); return processFinderPatternInfo(info); }
/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average * based on count. */ FinderPattern combineEstimate(float i, float j, float newModuleSize) { int combinedCount = count + 1; float combinedX = (count * getX() + j) / combinedCount; float combinedY = (count * getY() + i) / combinedCount; float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount; return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); }
/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. */ AlignmentPattern combineEstimate(float i, float j, float newModuleSize) { float combinedX = (getX() + j) / 2.0f; float combinedY = (getY() + i) / 2.0f; float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); }
/** * <p>Detects a QR Code in an image.</p> * * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ public DetectorResult detect() throws NotFoundException, FormatException { return detect(null); }
@Override public int compare(FinderPattern center1, FinderPattern center2) { float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; } }
/** * <p>Computes an average estimated module size based on estimated derived from the positions * of the three finder patterns.</p> * * @param topLeft detected top-left finder pattern center * @param topRight detected top-right finder pattern center * @param bottomLeft detected bottom-left finder pattern center * @return estimated module size */ protected final float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft) { // Take the average return (calculateModuleSizeOneWay(topLeft, topRight) + calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; }
/** * <p>Detects a QR Code in an image, simply.</p> * * @param hints optional hints to detector * @return {@link NotFoundException} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ public DetectorResult detect(Hashtable hints) throws NotFoundException, FormatException { resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback); FinderPatternInfo info = finder.find(hints); return processFinderPatternInfo(info); }
/** * <p>Detects a QR Code in an image, simply.</p> * * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if no QR Code can be found */ public DetectorResult detect() throws NotFoundException, FormatException { return detect(null); }
public int compare(Object center1, Object center2) { float value = ((FinderPattern) center2).getEstimatedModuleSize() - ((FinderPattern) center1).getEstimatedModuleSize(); return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; } }
/** * <p>Computes an average estimated module size based on estimated derived from the positions * of the three finder patterns.</p> * * @param topLeft detected top-left finder pattern center * @param topRight detected top-right finder pattern center * @param bottomLeft detected bottom-left finder pattern center * @return estimated module size */ protected final float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft) { // Take the average return (calculateModuleSizeOneWay(topLeft, topRight) + calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; }
@Override public int compare(FinderPattern center1, FinderPattern center2) { float dA = Math.abs(center2.getEstimatedModuleSize() - average); float dB = Math.abs(center1.getEstimatedModuleSize() - average); return dA < dB ? -1 : dA > dB ? 1 : 0; } }