Package com.google.zxing.qrcode.detector
Class Detector
- java.lang.Object
-
- com.google.zxing.qrcode.detector.Detector
-
- Direct Known Subclasses:
MultiDetector
public class Detector extends java.lang.ObjectEncapsulates logic that can detect a QR Code in an image, even if the QR Code is rotated or skewed, or partially obscured.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected floatcalculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft)Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.DetectorResultdetect()Detects a QR Code in an image.DetectorResultdetect(java.util.Map<DecodeHintType,?> hints)Detects a QR Code in an image.protected AlignmentPatternfindAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor)Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it.protected BitMatrixgetImage()protected ResultPointCallbackgetResultPointCallback()protected DetectorResultprocessFinderPatternInfo(FinderPatternInfo info)
-
-
-
Constructor Detail
-
Detector
public Detector(BitMatrix image)
-
-
Method Detail
-
getImage
protected final BitMatrix getImage()
-
getResultPointCallback
protected final ResultPointCallback getResultPointCallback()
-
detect
public DetectorResult detect() throws NotFoundException, FormatException
Detects a QR Code in an image.
- Returns:
DetectorResultencapsulating results of detecting a QR Code- Throws:
NotFoundException- if QR Code cannot be foundFormatException- if a QR Code cannot be decoded
-
detect
public final DetectorResult detect(java.util.Map<DecodeHintType,?> hints) throws NotFoundException, FormatException
Detects a QR Code in an image.
- Parameters:
hints- optional hints to detector- Returns:
DetectorResultencapsulating results of detecting a QR Code- Throws:
NotFoundException- if QR Code cannot be foundFormatException- if a QR Code cannot be decoded
-
processFinderPatternInfo
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) throws NotFoundException, FormatException
- Throws:
NotFoundExceptionFormatException
-
calculateModuleSize
protected final float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft)
Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.
- Parameters:
topLeft- detected top-left finder pattern centertopRight- detected top-right finder pattern centerbottomLeft- detected bottom-left finder pattern center- Returns:
- estimated module size
-
findAlignmentInRegion
protected final AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor) throws NotFoundException
Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. This method uses
AlignmentPattern.- Parameters:
overallEstModuleSize- estimated module size so farestAlignmentX- x coordinate of center of area probably containing alignment patternestAlignmentY- y coordinate of aboveallowanceFactor- number of pixels in all directions to search from the center- Returns:
AlignmentPatternif found, or null otherwise- Throws:
NotFoundException- if an unexpected error occurs during detection
-
-