Encapsulates an alignment pattern, which are the smaller square patterns found in all but the simplest QR Codes.
Encapsulates a point of interest in an image containing a barcode. Typically, this would be the location of a finder pattern or the corner of the barcode, for example.
Determines if this alignment pattern "about equals" an alignment pattern at the stated position and size -- meaning, it is at nearly the same center with nearly the same size.
QR Codes can encode text as bits in one of several modes, and can use multiple modes in one QR Code. This class decodes the bits back into text.
See ISO 18004:2006, 6.4.3 - 6.4.7
Encapsulates functionality and implementation that is common to UPC and EAN families of one-dimensional barcodes.
Implements decoding of the EAN-13 format.
Encapsulates functionality and implementation that is common to UPC and EAN families of one-dimensional barcodes.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Like {@link #decodeRow(int, BitArray, java.util.Hashtable)}, but allows caller to inform method about where the UPC/EAN start pattern is found. This allows this to be computed once and reused across many implementations.
Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code is rotated or skewed, or partially obscured.
Detects a Data Matrix Code in an image.
Comparator since it is not available in
CLDC 1.1 / MIDP 2.0.
Abstract class representing the result of decoding a barcode, as more than a String -- as some type of structured data. This might be a subclass which represents a URL, or an e-mail address. {@link #parseResult(com.google.zxing.Result)} will turn a raw decoded string into the most appropriate type of structured representation.
Thanks to Jeff Griffin for proposing rewrite of these classes that relies less on exception-based mechanisms during parsing.
Superclass for classes encapsulating results in the NDEF format. See http://www.nfc-forum.org/specs/.
This code supports a limited subset of NDEF messages, ones that are plausibly useful in 2D barcode formats. This generally includes 1-record messages, no chunking, "short record" syntax, no ID field.
Attempts to locate multiple barcodes in an image by repeatedly decoding portion of the image. After one barcode is found, the areas left, above, right and below the barcode's {@link com.google.zxing.ResultPoint}s are scanned, recursively.
A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent detecting any one of them.
That is, instead of passing a {@link Reader} a caller might pass
new ByQuadrantReader(reader).
Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into multiple blocks, each of which is a unit of data and error-correction codewords. Each is represented by an instance of this class.
When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This method will separate the data into original blocks.
Encapsulates a QR Code's format information, including the data mask used and error correction level.
null
if doesn't seem to match any known pattern
Represents a polynomial whose coefficients are elements of GF(256). Instances of this class are immutable.
Much credit is due to William Rucklidge since portions of this code are an indirect port of his C++ Reed-Solomon implementation.
Represents a 2D matrix of bits. In function arguments below, and throughout the common module, x is the column position, and y is the row position. The ordering is always x, y. The origin is at the top-left.
Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins with a new int. This is done intentionally so that we can copy out a row into a BitArray very efficiently.
The ordering of bits is row-major. Within each int, the least significant bits are used first, meaning they represent lower x values. This is compatible with BitArray's implementation.
Gets the requested bit, where true means black.
Sets the given bit to true.
Flips the given bit.
Sets a square region of the bit matrix to true.
Abstract class representing the result of decoding a barcode, as more than a String -- as some type of structured data. This might be a subclass which represents a URL, or an e-mail address. {@link ResultParser#parseResult(Result)} will turn a raw decoded string into the most appropriate type of structured representation.
Thanks to Jeff Griffin for proposing rewrite of these classes that relies less on exception-based mechanisms during parsing.
See DoCoMo's documentation about the result types represented by subclasses of this class.
Thanks to Jeff Griffin for proposing rewrite of these classes that relies less on exception-based mechanisms during parsing.
Encapsulates logic that can detect a QR Code in an image, even if the QR Code is rotated or skewed, or partially obscured.
Detects a QR Code in an image, simply.
Detects a QR Code in an image, simply.
Computes the dimension (number of modules on a size) of the QR Code based on the position of the finder patterns and estimated module size.
Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.
Estimates module size based on two finder patterns -- it uses {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the width of each, measuring along the axis between their centers.
This method traces a line from a point in the image, in the direction towards another point. It begins in a black region, and keeps going until it finds white, then black, then white again. It reports the distance from the start to this point.
This is used when figuring out how wide a finder pattern is, when the finder pattern may be skewed or rotated.
Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. This method uses {@link AlignmentPattern}.
The main class which implements QR Code decoding -- as opposed to locating and extracting the QR Code from an image.
Convenience method that can decode a QR Code represented as a 2D array of booleans. "true" is taken to mean a black module.
Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
Deduces version information from Data Matrix dimensions.
Encapsulates a set of error-correction blocks in one symbol version. Most versions will use blocks of differing sizes within one version, so, this encapsulates the parameters for each set of blocks. It also holds the number of error-correction codewords per block since it will be the same across all blocks within one version.
Encapsualtes the parameters for one error-correction block in one symbol version. This includes the number of data codewords, and the number of times a block with these parameters is used consecutively in the Data Matrix code version's format.
Implements Reed-Solomon decoding, as the name implies.
The algorithm will not be explained here, but the following references were helpful in creating this implementation:
Much credit is due to William Rucklidge since portions of this code are an indirect port of his C++ Reed-Solomon implementation.
Decodes given set of received codewords, which include both data and error-correction codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, in the input.
Encapsulates the result of detecting a barcode in an image. This includes the raw matrix of black/white pixels corresponding to the barcode, and possibly points of interest in the image, like the location of finder patterns or corners of the barcode in the image.
A simple, fast array of bits, represented compactly by an array of ints internally.
Encapsulates information about finder patterns in an image, including the location of the three finder patterns, and their estimated module size.
Encapsulates a block of data within a QR Code. QR Codes may split their data into multiple blocks, each of which is a unit of data and error-correction codewords. Each is represented by an instance of this class.
When QR Codes use multiple data blocks, they are actually interleaved. That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This method will separate the data into original blocks.
Creates a finder that will search the image for three finder patterns.
After a horizontal scan finds a potential finder pattern, this method "cross-checks" by scanning down vertically through the center of the possible finder pattern to see if the same proportion is detected.
Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, except it reads horizontally instead of vertically. This is used to cross-cross check a vertical cross check and locate the real center of the alignment pattern.
Orders by {@link FinderPattern#getCount()}, descending.
Creates a finder that will search the image for three finder patterns.
Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, including areas used for finder patterns, timing patterns, etc. These areas should be unused after the point they are unmasked anyway.
Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position and j is row position. In fact, as the text says, i is row position and j is column position.
Implementations of this method reverse the data masking process applied to a QR Code and make its bits ready to read.
Implements decoding of the EAN-8 format.
Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes in one Data Matrix Code. This class decodes the bits back into text.
See ISO 16022:2006, 5.2.1 - 5.2.9.2
Parses an "sms:" URI result, which specifies a number to SMS and optional "via" number. See the IETF draft on this.
This actually also parses URIs starting with "mms:", "smsto:", "mmsto:", "SMSTO:", and "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI for purposes of forwarding to the platform.
This class contains the methods for decoding the PDF417 codewords.
Implements decoding of the EAN-13 format.
Decodes Code 39 barcodes. This does not support "Full ASCII Code 39" yet.
Reads format information from one of its two locations within the QR Code.
Reads version information from one of its two locations within the QR Code.
Reads the bits in the {@link BitMatrix} representing the finder pattern in the correct order in order to reconstitute the codewords bytes contained within the QR Code.
Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code is rotated or skewed, or partially obscured.
Creates the version object based on the dimension of the original bit matrix from the datamatrix code.
See ISO 16022:2006 Table 7 - ECC 200 symbol attributes
Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) in the correct order in order to reconstitute the codewords bytes contained within the Data Matrix Code.
Reads a bit of the mapping matrix accounting for boundary wrapping.
Reads the 8 bits of the standard Utah-shaped pattern.
See ISO 16022:2006, 5.8.1 Figure 6
Reads the 8 bits of the special corner condition 1.
See ISO 16022:2006, Figure F.3
Reads the 8 bits of the special corner condition 2.
See ISO 16022:2006, Figure F.4
Reads the 8 bits of the special corner condition 3.
See ISO 16022:2006, Figure F.5
Reads the 8 bits of the special corner condition 4.
See ISO 16022:2006, Figure F.6
Extracts the data region from a {@link BitMatrix} that contains alignment patterns.
Implements decoding of the UPC-A format.
Samples an image for a square matrix of bits of the given dimension. This is used to extract the black/white modules of a 2D barcode like a QR Code found in an image. Because this barcode may be rotated or perspective-distorted, the caller supplies four points in the source image that define known points in the barcode, so that the image may be sampled appropriately.
The last eight "from" parameters are four X/Y coordinate pairs of locations of points in the image that define some significant points in the image to be sample. For example, these may be the location of finder pattern in a QR Code.
The first eight "to" parameters are four X/Y coordinate pairs measured in the destination {@link BitMatrix}, from the top left, where the known points in the image given by the "from" parameters map to.
These 16 parameters define the transformation needed to sample the image.
Checks a set of points that have been transformed to sample points on an image against the image's dimensions to see if the point are even within the image.
This method will actually "nudge" the endpoints back onto the image if they are found to be barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder patterns in an image where the QR Code runs all the way to the image border.
For efficiency, the method will check points from either end of the line until one is found to be within the image. Because the set of points are assumed to be linear, this is valid.
Deduces version information purely from QR Code dimensions.
Encapsulates a set of error-correction blocks in one symbol version. Most versions will use blocks of differing sizes within one version, so, this encapsulates the parameters for each set of blocks. It also holds the number of error-correction codewords per block since it will be the same across all blocks within one version.
Encapsualtes the parameters for one error-correction block in one symbol version. This includes the number of data codewords, and the number of times a block with these parameters is used consecutively in the QR code version's format.
Encapsulates logic that can detect a PDF417 Code in an image, even if the PDF417 Code is rotated or skewed, or partially obscured.
Detects a PDF417 Code in an image, simply.
Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.
Estimates module size (pixels in a module) based on the Start and End finder patterns.
This is basically a substitute for java.util.Collections, which is not
present in MIDP 2.0 / CLDC 1.1.
See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which data can be encoded to bits in the QR code standard.
Implements decoding of the UPC-E format.
This is a great reference for UPC-E information.
A reader that can read all available UPC/EAN formats. If a caller wants to try to read all such formats, it is most efficient to use this implementation rather than invoke individual readers.
Decodes Code 128 barcodes.
Implements Reed-Solomon enbcoding, as the name implies.
Recognizes an NDEF message that encodes information according to the "Smart Poster Record Type Definition" specification.
This actually only supports some parts of the Smart Poster format: title, URI, and action records. Icon records are not supported because the size of these records are infeasibly large for barcodes. Size and type records are not supported. Multiple titles are not supported.
2D barcode formats typically encode text, but allow for a sort of 'byte mode' which is sometimes used to encode binary data. While {@link Result} makes available the complete raw bytes in the barcode for these formats, it does not offer the bytes from the byte segments alone.
This maps to a {@link java.util.Vector} of byte arrays corresponding to the raw bytes in the byte segments in the barcode, in order.
See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels defined by the QR code standard.
Implements decoding of the ITF format.
"ITF" stands for Interleaved Two of Five. This Reader will scan ITF barcode with 6, 10 or 14 digits. 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.
This class contains utility methods for performing mathematical operations over the Galois Field GF(256). Operations use a given primitive polynomial in calculations.
Throughout this package, elements of GF(256) are represented as an int
for convenience and speed (but at the cost of memory).
Only the bottom 8 bits are really used.
A somewhat generic detector that looks for a barcode-like rectangular region within an image. It looks within a mostly white region of an image for a region of black and white, but mostly black. It returns the four corners of the region, as best it can determine.
Detects a rectangular region of black and white -- mostly black -- with a region of mostly white, in an image.
This provides an easy abstraction to read bits at a time from a sequence of bytes, where the number of bits read is not often a multiple of 8.
This class is thread-safe but not reentrant. Unless the caller modifies the bytes array it passed in, in which case all bets are off.
Encapsulates the result of decoding a barcode within an image.
null
null
null. This contains optional metadata about what was detected about the barcode,
like orientation.
Encapsulates the result of decoding a matrix of bits. This typically applies to 2D barcode formats. For now it contains the raw bytes obtained, as well as a String interpretation of those bytes, if applicable.
The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting the Data Matrix Code from an image.
Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. "true" is taken to mean a black module.
Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
This class implements a perspective transform in two dimensions. Given four source and four destination points, it will compute the transformation implied between them. The code is based directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.
The main class which implements PDF417 Code decoding -- as opposed to locating and extracting the PDF417 Code from an image.
Convenience method that can decode a PDF417 Code represented as a 2D array of booleans. "true" is taken to mean a black module.
Decodes a PDF417 Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
Encapsulates a finder pattern, which are the three square patterns found in the corners of QR Codes. It also encapsulates a count of similar finder patterns, as a convenience to the finder's bookkeeping.
Determines if this finder pattern "about equals" a finder pattern at the stated position and size -- meaning, it is at nearly the same center with nearly the same size.
Creates a finder that will look in a portion of the whole image.
This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since it's pretty performance-critical and so is written to be fast foremost.
After a horizontal scan finds a potential alignment pattern, this method "cross-checks" by scanning down vertically through the center of the possible alignment pattern to see if the same proportion is detected.
This is called when a horizontal scan finds a possible alignment pattern. It will cross check with a vertical scan, and if successful, will see if this pattern had been found on a previous horizontal scan. If so, we consider it confirmed and conclude we have found the alignment pattern.
This class parses the BitMatrix image into codewords.
Thrown when an exception occurs during Reed-Solomon decoding, such as when there are too many errors to correct.
Represents a record in an NDEF message. This class only supports certain types of records -- namely, non-chunked records, where ID length is omitted, and only "short records".