Package com.google.zxing.pdf417.detector
Class Detector
java.lang.Object
com.google.zxing.pdf417.detector.Detector
Encapsulates logic that can detect a PDF417 Code in an image, even if the PDF417 Code is rotated or skewed, or partially obscured.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int[]
private static final int[]
private static final float
private static final float
private static final int
private static final int
private static final float
private static final int[]
private static final int
private static final int
private static final int[]
private static final int[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static BitMatrix
applyRotation
(BitMatrix matrix, int rotation) Applies a rotation to the supplied BitMatrix.private static void
copyToResult
(ResultPoint[] result, ResultPoint[] tmpResult, int[] destinationIndexes) private static List
<ResultPoint[]> Detects PDF417 codes in an image.static PDF417DetectorResult
detect
(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) Detects a PDF417 Code in an image.private static int[]
findGuardPattern
(BitMatrix matrix, int column, int row, int width, int[] pattern, int[] counters) private static ResultPoint[]
findRowsWithPattern
(BitMatrix matrix, int height, int width, int startRow, int startColumn, int minHeight, int[] pattern) private static ResultPoint[]
findVertices
(BitMatrix matrix, int startRow, int startColumn) Locate the vertices and the codewords area of a black blob using the Start and Stop patterns as locators.private static float
patternMatchVariance
(int[] counters, int[] pattern) Determines how closely a set of observed counts of runs of black/white values matches a given target pattern.
-
Field Details
-
INDEXES_START_PATTERN
private static final int[] INDEXES_START_PATTERN -
INDEXES_STOP_PATTERN
private static final int[] INDEXES_STOP_PATTERN -
MAX_AVG_VARIANCE
private static final float MAX_AVG_VARIANCE- See Also:
-
MAX_INDIVIDUAL_VARIANCE
private static final float MAX_INDIVIDUAL_VARIANCE- See Also:
-
MAX_STOP_PATTERN_HEIGHT_VARIANCE
private static final float MAX_STOP_PATTERN_HEIGHT_VARIANCE- See Also:
-
START_PATTERN
private static final int[] START_PATTERN -
STOP_PATTERN
private static final int[] STOP_PATTERN -
MAX_PIXEL_DRIFT
private static final int MAX_PIXEL_DRIFT- See Also:
-
MAX_PATTERN_DRIFT
private static final int MAX_PATTERN_DRIFT- See Also:
-
SKIPPED_ROW_COUNT_MAX
private static final int SKIPPED_ROW_COUNT_MAX- See Also:
-
ROW_STEP
private static final int ROW_STEP- See Also:
-
BARCODE_MIN_HEIGHT
private static final int BARCODE_MIN_HEIGHT- See Also:
-
ROTATIONS
private static final int[] ROTATIONS
-
-
Constructor Details
-
Detector
private Detector()
-
-
Method Details
-
detect
public static PDF417DetectorResult detect(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) throws NotFoundExceptionDetects a PDF417 Code in an image. Checks 0, 90, 180, and 270 degree rotations.
- Parameters:
image
- barcode image to decodehints
- optional hints to detectormultiple
- if true, then the image is searched for multiple codes. If false, then at most one code will be found and returned- Returns:
PDF417DetectorResult
encapsulating results of detecting a PDF417 code- Throws:
NotFoundException
- if no PDF417 Code can be found
-
applyRotation
Applies a rotation to the supplied BitMatrix.- Parameters:
matrix
- bit matrix to apply rotation torotation
- the degrees of rotation to apply- Returns:
- BitMatrix with applied rotation
-
detect
Detects PDF417 codes in an image. Only checks 0 degree rotation- Parameters:
multiple
- if true, then the image is searched for multiple codes. If false, then at most one code will be found and returnedbitMatrix
- bit matrix to detect barcodes in- Returns:
- List of ResultPoint arrays containing the coordinates of found barcodes
-
findVertices
Locate the vertices and the codewords area of a black blob using the Start and Stop patterns as locators.- Parameters:
matrix
- the scanned barcode image.- Returns:
- an array containing the vertices: vertices[0] x, y top left barcode vertices[1] x, y bottom left barcode vertices[2] x, y top right barcode vertices[3] x, y bottom right barcode vertices[4] x, y top left codeword area vertices[5] x, y bottom left codeword area vertices[6] x, y top right codeword area vertices[7] x, y bottom right codeword area
-
copyToResult
private static void copyToResult(ResultPoint[] result, ResultPoint[] tmpResult, int[] destinationIndexes) -
findRowsWithPattern
private static ResultPoint[] findRowsWithPattern(BitMatrix matrix, int height, int width, int startRow, int startColumn, int minHeight, int[] pattern) -
findGuardPattern
private static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, int[] pattern, int[] counters) - Parameters:
matrix
- row of black/white values to searchcolumn
- x position to start searchrow
- y position to start searchwidth
- the number of pixels to search on this rowpattern
- pattern of counts of number of black and white pixels that are being searched for as a patterncounters
- array of counters, as long as pattern, to re-use- Returns:
- start/end horizontal offset of guard pattern, as an array of two ints.
-
patternMatchVariance
private static float patternMatchVariance(int[] counters, int[] pattern) Determines how closely a set of observed counts of runs of black/white values matches a given target pattern. This is reported as the ratio of the total variance from the expected pattern proportions across all pattern elements, to the length of the pattern.- Parameters:
counters
- observed counterspattern
- expected pattern- Returns:
- ratio of total variance between counters and pattern compared to total pattern size
-