com.google.zxing.oned
Class AbstractOneDReader

java.lang.Object
  extended by com.google.zxing.oned.AbstractOneDReader
All Implemented Interfaces:
OneDReader, Reader
Direct Known Subclasses:
AbstractUPCEANReader, CodaBarReader, Code128Reader, Code39Reader, Code93Reader, ITFReader, MultiFormatOneDReader, MultiFormatUPCEANReader

public abstract class AbstractOneDReader
extends Object
implements OneDReader

Encapsulates functionality and implementation that is common to all families of one-dimensional barcodes.

Since:
BlackBerry API 6.0.0

Field Summary
protected static int INTEGER_MATH_SHIFT
           
protected static int PATTERN_MATCH_RESULT_SCALE_FACTOR
           
 
Constructor Summary
AbstractOneDReader()
           
 
Method Summary
 Result decode(BinaryBitmap image)
          Locates and decodes a barcode in some format within an image.
 Result decode(BinaryBitmap image, Hashtable hints)
          Locates and decodes a barcode in some format within an image.
abstract  Result decodeRow(int rowNumber, BitArray row, Hashtable hints)
          Attempts to decode a one-dimensional barcode format given a single row of an image.
protected static int patternMatchVariance(int[] counters, int[] pattern, int maxIndividualVariance)
          Determines how closely a set of observed counts of runs of black/white values matches a given target pattern.
protected static void recordPattern(BitArray row, int start, int[] counters)
          Records the size of successive runs of white and black pixels in a row, starting at a given point.
protected static void recordPatternInReverse(BitArray row, int start, int[] counters)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

INTEGER_MATH_SHIFT

protected static final int INTEGER_MATH_SHIFT
See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

PATTERN_MATCH_RESULT_SCALE_FACTOR

protected static final int PATTERN_MATCH_RESULT_SCALE_FACTOR
See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0


Constructor Detail

AbstractOneDReader

public AbstractOneDReader()
Since:
BlackBerry API 6.0.0


Method Detail

decode

public Result decode(BinaryBitmap image)
              throws NotFoundException,
                     FormatException
Description copied from interface: Reader
Locates and decodes a barcode in some format within an image.

Specified by:
decode in interface Reader
Parameters:
image - image of barcode to decode
Returns:
String which the barcode encodes
Throws:
NotFoundException - if the barcode cannot be located or decoded for any reason
FormatException
Since:
BlackBerry API 6.0.0

decode

public Result decode(BinaryBitmap image,
                     Hashtable hints)
              throws NotFoundException,
                     FormatException
Description copied from interface: Reader
Locates and decodes a barcode in some format within an image. This method also accepts hints, each possibly associated to some data, which may help the implementation decode.

Specified by:
decode in interface Reader
Parameters:
image - image of barcode to decode
hints - passed as a Hashtable from DecodeHintType to arbitrary data. The meaning of the data depends upon the hint type. The implementation may or may not do anything with these hints.
Returns:
String which the barcode encodes
Throws:
NotFoundException - if the barcode cannot be located or decoded for any reason
FormatException
Since:
BlackBerry API 6.0.0

recordPattern

protected static void recordPattern(BitArray row,
                                    int start,
                                    int[] counters)
                             throws NotFoundException
Records the size of successive runs of white and black pixels in a row, starting at a given point. The values are recorded in the given array, and the number of runs recorded is equal to the size of the array. If the row starts on a white pixel at the given start point, then the first count recorded is the run of white pixels starting from that point; likewise it is the count of a run of black pixels if the row begin on a black pixels at that point.

Parameters:
row - row to count from
start - offset into row to start at
counters - array into which to record counts
Throws:
NotFoundException - if counters cannot be filled entirely from row before running out of pixels
Since:
BlackBerry API 7.0.0

recordPatternInReverse

protected static void recordPatternInReverse(BitArray row,
                                             int start,
                                             int[] counters)
                                      throws NotFoundException
Throws:
NotFoundException
Since:
BlackBerry API 7.0.0

patternMatchVariance

protected static int patternMatchVariance(int[] counters,
                                          int[] pattern,
                                          int maxIndividualVariance)
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 counters
pattern - expected pattern
maxIndividualVariance - The most any counter can differ before we give up
Returns:
ratio of total variance between counters and pattern compared to total pattern size, where the ratio has been multiplied by 256. So, 0 means no variance (perfect match); 256 means the total variance between counters and patterns equals the pattern length, higher values mean even more variance
Since:
BlackBerry API 7.0.0

decodeRow

public abstract Result decodeRow(int rowNumber,
                                 BitArray row,
                                 Hashtable hints)
                          throws NotFoundException,
                                 ChecksumException,
                                 FormatException

Attempts to decode a one-dimensional barcode format given a single row of an image.

Specified by:
decodeRow in interface OneDReader
Parameters:
rowNumber - row number from top of the row
row - the black/white pixel data of the row
hints - decode hints
Returns:
Result containing encoded string and start/end of barcode
Throws:
NotFoundException - if an error occurs or barcode cannot be found
ChecksumException
FormatException
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal