Class PDF417ScanningDecoder


  • public final class PDF417ScanningDecoder
    extends java.lang.Object
    • Constructor Detail

      • PDF417ScanningDecoder

        private PDF417ScanningDecoder()
    • Method Detail

      • getMax

        private static int getMax​(int[] values)
      • 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 erasures
        ambiguousIndexes - array with the indexes that have more than one most likely value
        ambiguousIndexValues - two dimensional array that contains the ambiguous values. The first dimension must be the same length as the ambiguousIndexes array
        Throws:
        FormatException
        ChecksumException
      • isValidBarcodeColumn

        private static boolean isValidBarcodeColumn​(DetectionResult detectionResult,
                                                    int barcodeColumn)
      • getStartColumn

        private static int getStartColumn​(DetectionResult detectionResult,
                                          int barcodeColumn,
                                          int imageRow,
                                          boolean leftToRight)
      • detectCodeword

        private static Codeword detectCodeword​(BitMatrix image,
                                               int minColumn,
                                               int maxColumn,
                                               boolean leftToRight,
                                               int startColumn,
                                               int imageRow,
                                               int minCodewordWidth,
                                               int maxCodewordWidth)
      • 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)
      • 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 codewords
        erasures - positions of any known erasures
        numECCodewords - number of error correction codewords that are available in codewords
        Throws:
        ChecksumException - if error correction fails
      • verifyCodewordCount

        private static void verifyCodewordCount​(int[] codewords,
                                                int numECCodewords)
                                         throws FormatException
        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

        public static java.lang.String toString​(BarcodeValue[][] barcodeMatrix)