public final class Detector
extends java.lang.Object
Encapsulates logic that can detect a PDF417 Code in an image, even if the PDF417 Code is rotated or skewed, or partially obscured.
Modifier and Type | Field and Description |
---|---|
private static int |
BARCODE_MIN_HEIGHT |
private static int[] |
INDEXES_START_PATTERN |
private static int[] |
INDEXES_STOP_PATTERN |
private static float |
MAX_AVG_VARIANCE |
private static float |
MAX_INDIVIDUAL_VARIANCE |
private static int |
MAX_PATTERN_DRIFT |
private static int |
MAX_PIXEL_DRIFT |
private static float |
MAX_STOP_PATTERN_HEIGHT_VARIANCE |
private static int[] |
ROTATIONS |
private static int |
ROW_STEP |
private static int |
SKIPPED_ROW_COUNT_MAX |
private static int[] |
START_PATTERN |
private static int[] |
STOP_PATTERN |
Modifier | Constructor and Description |
---|---|
private |
Detector() |
Modifier and Type | Method and Description |
---|---|
private static BitMatrix |
applyRotation(BitMatrix matrix,
int rotation)
Applies a rotation to the supplied BitMatrix.
|
private static void |
copyToResult(ResultPoint[] result,
ResultPoint[] tmpResult,
int[] destinationIndexes) |
static PDF417DetectorResult |
detect(BinaryBitmap image,
java.util.Map<DecodeHintType,?> hints,
boolean multiple)
Detects a PDF417 Code in an image.
|
private static java.util.List<ResultPoint[]> |
detect(boolean multiple,
BitMatrix bitMatrix)
Detects PDF417 codes 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.
|
private static final int[] INDEXES_START_PATTERN
private static final int[] INDEXES_STOP_PATTERN
private static final float MAX_AVG_VARIANCE
private static final float MAX_INDIVIDUAL_VARIANCE
private static final float MAX_STOP_PATTERN_HEIGHT_VARIANCE
private static final int[] START_PATTERN
private static final int[] STOP_PATTERN
private static final int MAX_PIXEL_DRIFT
private static final int MAX_PATTERN_DRIFT
private static final int SKIPPED_ROW_COUNT_MAX
private static final int ROW_STEP
private static final int BARCODE_MIN_HEIGHT
private static final int[] ROTATIONS
public static PDF417DetectorResult detect(BinaryBitmap image, java.util.Map<DecodeHintType,?> hints, boolean multiple) throws NotFoundException
Detects a PDF417 Code in an image. Checks 0, 90, 180, and 270 degree rotations.
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 returnedPDF417DetectorResult
encapsulating results of detecting a PDF417 codeNotFoundException
- if no PDF417 Code can be foundprivate static BitMatrix applyRotation(BitMatrix matrix, int rotation)
matrix
- bit matrix to apply rotation torotation
- the degrees of rotation to applyprivate static java.util.List<ResultPoint[]> detect(boolean multiple, BitMatrix bitMatrix)
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 inprivate static ResultPoint[] findVertices(BitMatrix matrix, int startRow, int startColumn)
matrix
- the scanned barcode image.private static void copyToResult(ResultPoint[] result, ResultPoint[] tmpResult, int[] destinationIndexes)
private static ResultPoint[] findRowsWithPattern(BitMatrix matrix, int height, int width, int startRow, int startColumn, int minHeight, int[] pattern)
private static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, int[] pattern, int[] counters)
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-useprivate static float patternMatchVariance(int[] counters, int[] pattern)
counters
- observed counterspattern
- expected pattern