public class Detector extends Object
Encapsulates logic that can detect a QR Code in an image, even if the QR Code is rotated or skewed, or partially obscured.
Modifier and Type | Method and Description |
---|---|
protected 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.
|
DetectorResult |
detect()
Detects a QR Code in an image.
|
DetectorResult |
detect(Map<DecodeHintType,?> hints)
Detects a QR Code in an image.
|
protected AlignmentPattern |
findAlignmentInRegion(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 BitMatrix |
getImage() |
protected ResultPointCallback |
getResultPointCallback() |
protected DetectorResult |
processFinderPatternInfo(FinderPatternInfo info) |
public Detector(BitMatrix image)
protected final BitMatrix getImage()
protected final ResultPointCallback getResultPointCallback()
public DetectorResult detect() throws NotFoundException, FormatException
Detects a QR Code in an image.
DetectorResult
encapsulating results of detecting a QR CodeNotFoundException
- if QR Code cannot be foundFormatException
- if a QR Code cannot be decodedpublic final DetectorResult detect(Map<DecodeHintType,?> hints) throws NotFoundException, FormatException
Detects a QR Code in an image.
hints
- optional hints to detectorDetectorResult
encapsulating results of detecting a QR CodeNotFoundException
- if QR Code cannot be foundFormatException
- if a QR Code cannot be decodedprotected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) throws NotFoundException, FormatException
NotFoundException
FormatException
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.
topLeft
- detected top-left finder pattern centertopRight
- detected top-right finder pattern centerbottomLeft
- detected bottom-left finder pattern centerprotected 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
.
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 centerAlignmentPattern
if found, or null otherwiseNotFoundException
- if an unexpected error occurs during detectionCopyright © 2007–2024. All rights reserved.