Class PDF417ScanningDecoder
java.lang.Object
com.google.zxing.pdf417.decoder.PDF417ScanningDecoder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final ErrorCorrectionprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static BoundingBoxadjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn) private static voidadjustCodewordCount(DetectionResult detectionResult, BarcodeValue[][] barcodeMatrix) private static intadjustCodewordStartColumn(BitMatrix image, int minColumn, int maxColumn, boolean leftToRight, int codewordStartColumn, int imageRow) private static booleancheckCodewordSkew(int codewordSize, int minCodewordWidth, int maxCodewordWidth) private static intcorrectErrors(int[] codewords, int[] erasures, int numECCodewords) Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place.private static BarcodeValue[][]createBarcodeMatrix(DetectionResult detectionResult) private static DecoderResultcreateDecoderResult(DetectionResult detectionResult) private static DecoderResultcreateDecoderResultFromAmbiguousValues(int ecLevel, int[] codewords, int[] erasureArray, int[] ambiguousIndexes, int[][] ambiguousIndexValues) This method deals with the fact, that the decoding process doesn't always yield a single most likely value.static DecoderResultdecode(BitMatrix image, ResultPoint imageTopLeft, ResultPoint imageBottomLeft, ResultPoint imageTopRight, ResultPoint imageBottomRight, int minCodewordWidth, int maxCodewordWidth) private static DecoderResultdecodeCodewords(int[] codewords, int ecLevel, int[] erasures) private static CodeworddetectCodeword(BitMatrix image, int minColumn, int maxColumn, boolean leftToRight, int startColumn, int imageRow, int minCodewordWidth, int maxCodewordWidth) private static BarcodeMetadatagetBarcodeMetadata(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, DetectionResultRowIndicatorColumn rightRowIndicatorColumn) private static int[]getBitCountForCodeword(int codeword) private static intgetCodewordBucketNumber(int codeword) private static intgetCodewordBucketNumber(int[] moduleBitCount) private static intgetMax(int[] values) private static int[]getModuleBitCount(BitMatrix image, int minColumn, int maxColumn, boolean leftToRight, int startColumn, int imageRow) private static intgetNumberOfECCodeWords(int barcodeECLevel) private static DetectionResultRowIndicatorColumngetRowIndicatorColumn(BitMatrix image, BoundingBox boundingBox, ResultPoint startPoint, boolean leftToRight, int minCodewordWidth, int maxCodewordWidth) private static intgetStartColumn(DetectionResult detectionResult, int barcodeColumn, int imageRow, boolean leftToRight) private static booleanisValidBarcodeColumn(DetectionResult detectionResult, int barcodeColumn) private static DetectionResultmerge(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, DetectionResultRowIndicatorColumn rightRowIndicatorColumn) static StringtoString(BarcodeValue[][] barcodeMatrix) private static voidverifyCodewordCount(int[] codewords, int numECCodewords) Verify that all is OK with the codeword array.
-
Field Details
-
CODEWORD_SKEW_SIZE
private static final int CODEWORD_SKEW_SIZE- See Also:
-
MAX_ERRORS
private static final int MAX_ERRORS- See Also:
-
MAX_EC_CODEWORDS
private static final int MAX_EC_CODEWORDS- See Also:
-
errorCorrection
-
-
Constructor Details
-
PDF417ScanningDecoder
private PDF417ScanningDecoder()
-
-
Method Details
-
decode
public static DecoderResult decode(BitMatrix image, ResultPoint imageTopLeft, ResultPoint imageBottomLeft, ResultPoint imageTopRight, ResultPoint imageBottomRight, int minCodewordWidth, int maxCodewordWidth) throws NotFoundException, FormatException, ChecksumException -
merge
private static DetectionResult merge(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, DetectionResultRowIndicatorColumn rightRowIndicatorColumn) throws NotFoundException - Throws:
NotFoundException
-
adjustBoundingBox
private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn) throws NotFoundException - Throws:
NotFoundException
-
getMax
private static int getMax(int[] values) -
getBarcodeMetadata
private static BarcodeMetadata getBarcodeMetadata(DetectionResultRowIndicatorColumn leftRowIndicatorColumn, DetectionResultRowIndicatorColumn rightRowIndicatorColumn) -
getRowIndicatorColumn
private static DetectionResultRowIndicatorColumn getRowIndicatorColumn(BitMatrix image, BoundingBox boundingBox, ResultPoint startPoint, boolean leftToRight, int minCodewordWidth, int maxCodewordWidth) -
adjustCodewordCount
private static void adjustCodewordCount(DetectionResult detectionResult, BarcodeValue[][] barcodeMatrix) throws NotFoundException - Throws:
NotFoundException
-
createDecoderResult
private static DecoderResult createDecoderResult(DetectionResult detectionResult) throws FormatException, ChecksumException, NotFoundException -
createDecoderResultFromAmbiguousValues
private static DecoderResult createDecoderResultFromAmbiguousValues(int ecLevel, int[] codewords, int[] erasureArray, int[] ambiguousIndexes, int[][] ambiguousIndexValues) throws FormatException, ChecksumException This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The current error correction implementation doesn't deal with erasures very well, so it's better to provide a value for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes, so decoding the normal barcodes is not affected by this.- Parameters:
erasureArray- contains the indexes of erasuresambiguousIndexes- array with the indexes that have more than one most likely valueambiguousIndexValues- two dimensional array that contains the ambiguous values. The first dimension must be the same length as the ambiguousIndexes array- Throws:
FormatExceptionChecksumException
-
createBarcodeMatrix
-
isValidBarcodeColumn
-
getStartColumn
private static int getStartColumn(DetectionResult detectionResult, int barcodeColumn, int imageRow, boolean leftToRight) -
detectCodeword
-
getModuleBitCount
private static int[] getModuleBitCount(BitMatrix image, int minColumn, int maxColumn, boolean leftToRight, int startColumn, int imageRow) -
getNumberOfECCodeWords
private static int getNumberOfECCodeWords(int barcodeECLevel) -
adjustCodewordStartColumn
private static int adjustCodewordStartColumn(BitMatrix image, int minColumn, int maxColumn, boolean leftToRight, int codewordStartColumn, int imageRow) -
checkCodewordSkew
private static boolean checkCodewordSkew(int codewordSize, int minCodewordWidth, int maxCodewordWidth) -
decodeCodewords
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException, ChecksumException - Throws:
FormatExceptionChecksumException
-
correctErrors
private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws ChecksumException Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place.
- Parameters:
codewords- data and error correction codewordserasures- positions of any known erasuresnumECCodewords- number of error correction codewords that are available in codewords- Throws:
ChecksumException- if error correction fails
-
verifyCodewordCount
Verify that all is OK with the codeword array.- Throws:
FormatException
-
getBitCountForCodeword
private static int[] getBitCountForCodeword(int codeword) -
getCodewordBucketNumber
private static int getCodewordBucketNumber(int codeword) -
getCodewordBucketNumber
private static int getCodewordBucketNumber(int[] moduleBitCount) -
toString
-