public final class ITFReader extends OneDReader
Implements decoding of the ITF format, or Interleaved Two of Five.
This Reader will scan ITF barcodes of certain lengths only. At the moment it reads length 6, 8, 10, 12, 14, 16, 18, 20, 24, and 44 as these have appeared "in the wild". Not all lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of required checksum function.
The checksum is optional and is not applied by this Reader. The consumer of the decoded value will have to apply a checksum if required.
http://en.wikipedia.org/wiki/Interleaved_2_of_5 is a great reference for Interleaved 2 of 5 information.
Modifier and Type | Field and Description |
---|---|
private static int[] |
DEFAULT_ALLOWED_LENGTHS
Valid ITF lengths.
|
private static int[][] |
END_PATTERN_REVERSED |
private static float |
MAX_AVG_VARIANCE |
private static float |
MAX_INDIVIDUAL_VARIANCE |
private static int |
N |
private int |
narrowLineWidth |
private static int[][] |
PATTERNS
Patterns of Wide / Narrow lines to indicate each digit
|
private static int[] |
START_PATTERN
Start/end guard pattern.
|
private static int |
w |
private static int |
W |
Constructor and Description |
---|
ITFReader() |
Modifier and Type | Method and Description |
---|---|
private static int |
decodeDigit(int[] counters)
Attempts to decode a sequence of ITF black/white lines into single
digit.
|
private int[] |
decodeEnd(BitArray row)
Identify where the end of the middle / payload section ends.
|
private static void |
decodeMiddle(BitArray row,
int payloadStart,
int payloadEnd,
java.lang.StringBuilder resultString) |
Result |
decodeRow(int rowNumber,
BitArray row,
java.util.Map<DecodeHintType,?> hints)
Attempts to decode a one-dimensional barcode format given a single row of
an image.
|
private int[] |
decodeStart(BitArray row)
Identify where the start of the middle / payload section starts.
|
private static int[] |
findGuardPattern(BitArray row,
int rowOffset,
int[] pattern) |
private static int |
skipWhiteSpace(BitArray row)
Skip all whitespace until we get to the first black line.
|
private void |
validateQuietZone(BitArray row,
int startPattern)
The start & end patterns must be pre/post fixed by a quiet zone.
|
decode, decode, patternMatchVariance, recordPattern, recordPatternInReverse, reset
private static final float MAX_AVG_VARIANCE
private static final float MAX_INDIVIDUAL_VARIANCE
private static final int W
private static final int w
private static final int N
private static final int[] DEFAULT_ALLOWED_LENGTHS
private int narrowLineWidth
private static final int[] START_PATTERN
private static final int[][] END_PATTERN_REVERSED
private static final int[][] PATTERNS
public Result decodeRow(int rowNumber, BitArray row, java.util.Map<DecodeHintType,?> hints) throws FormatException, NotFoundException
OneDReader
Attempts to decode a one-dimensional barcode format given a single row of an image.
decodeRow
in class OneDReader
rowNumber
- row number from top of the rowrow
- the black/white pixel data of the rowhints
- decode hintsResult
containing encoded string and start/end of barcodeFormatException
- if a potential barcode is found but format is invalidNotFoundException
- if no potential barcode is foundprivate static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, java.lang.StringBuilder resultString) throws NotFoundException
row
- row of black/white values to searchpayloadStart
- offset of start patternresultString
- StringBuilder
to append decoded chars toNotFoundException
- if decoding could not complete successfullyprivate int[] decodeStart(BitArray row) throws NotFoundException
row
- row of black/white values to searchNotFoundException
private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException
row
- bit array representing the scanned barcode.startPattern
- index into row of the start or end pattern.NotFoundException
- if the quiet zone cannot be foundprivate static int skipWhiteSpace(BitArray row) throws NotFoundException
row
- row of black/white values to searchNotFoundException
- Throws exception if no black lines are found in the rowprivate int[] decodeEnd(BitArray row) throws NotFoundException
row
- row of black/white values to searchNotFoundException
private static int[] findGuardPattern(BitArray row, int rowOffset, int[] pattern) throws NotFoundException
row
- row of black/white values to searchrowOffset
- position to start searchpattern
- pattern of counts of number of black and white pixels that are
being searched for as a patternNotFoundException
- if pattern is not foundprivate static int decodeDigit(int[] counters) throws NotFoundException
counters
- the counts of runs of observed black/white/black/... valuesNotFoundException
- if digit cannot be decoded