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.
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.
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.
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.
Parses an "smsto:" URI result, whose format is not standardized but appears to be like: {@code smsto:number(:body)}.
This actually also parses URIs starting with "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.
Parses an "smtp:" URI result, whose format is not standardized but appears to be like:
smtp[:subject[:body]]}
.
See http://code.google.com/p/zxing/issues/detail?id=536
Parses a WIFI configuration string. Strings will be of the form:
{@code WIFI:T:[network type];S:[network SSID];P:[network password];H:[hidden?];;}
The fields can appear in any order. Only "S:" is required.
For WPA2 enterprise(EAP), strings will be of the form:
{@code WIFI:T:WPA2-EAP;S:[network SSID];H:[hidden?];E:[EAP method];PH2:[Phase 2 method];A:[anonymous identity];I:[username];P:[password];;}
"EAP method" can e.g.be "TTLS" or "PWD" or one of the other fields in WifiEnterpriseConfig.Eap and "Phase 2 method" can e.g.be "MSCHAPV2" or any of the other fields in WifiEnterpriseConfig.Phase2
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
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
Gets the requested bit, where true means black.
Flips the given bit.
Flips every bit in the matrix.
Sets a square region of the bit matrix to true.
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 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 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.
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
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.
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.
This class contains utility methods for performing mathematical operations over the Galois Fields. Operations use a given primitive polynomial in calculations.
Throughout this package, elements of the GF are represented as an {@code int} for convenience and speed (but at the cost of memory).
Represents a polynomial whose coefficients are elements of a GF. 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.
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.
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
OriginalReads the bits in the
Reads a bit of the mapping matrix accounting for boundary wrapping.
Row to read in the mapping matrix Column to read in the mapping matrix Number of rows in the mapping matrix Number of columns in the mapping matrixReads the 8 bits of the standard Utah-shaped pattern.
See ISO 16022:2006, 5.8.1 Figure 6
Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern Number of rows in the mapping matrix Number of columns in the mapping matrixReads the 8 bits of the special corner condition 1.
See ISO 16022:2006, Figure F.3
Number of rows in the mapping matrix Number of columns in the mapping matrixReads the 8 bits of the special corner condition 2.
See ISO 16022:2006, Figure F.4
Number of rows in the mapping matrix Number of columns in the mapping matrixReads the 8 bits of the special corner condition 3.
See ISO 16022:2006, Figure F.5
Number of rows in the mapping matrix Number of columns in the mapping matrixReads the 8 bits of the special corner condition 4.
See ISO 16022:2006, Figure F.6
Number of rows in the mapping matrix Number of columns in the mapping matrixExtracts the data region from a
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.
bytes as read directly from the Data Matrix Code version of the Data Matrix CodeData 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
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.
booleans representing white/black Data Matrix Code modulesDecodes a Data Matrix Code represented as a
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
data and error correction codewords number of codewords that are data bytesDeduces version information from Data Matrix dimensions.
Number of rows in modules Number of columns in modulesEncapsulates 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.
Encapsulates 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.
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.
Attempts to decode a one-dimensional barcode format given a single row of an image.
int luminance = array[y * width + x] & 0xff
MaxiCodes can encode text or structured information as bits in one of several modes, with multiple character sets in one code. This class decodes the bits back into text.
The main class which implements MaxiCode decoding -- as opposed to locating and extracting the MaxiCode from an image.
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 logic that can detect one or more QR Codes in an image, even if the QR Code is rotated or skewed, or partially obscured.
This class attempts to find finder patterns in a QR Code. Finder patterns are the square markers at three corners of a QR Code.
This class is thread-safe but not reentrant. Each thread must allocate its own object.
In contrast to
Use the TRY_HARDER hint to ask for a more thorough detection.
Creates a finder that will search the image for three finder patterns.
image to search callback for result pointsDecodes Codabar barcodes.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Decodes Code 128 barcodes.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Decodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Decodes Code 93 barcodes.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Implements decoding of the EAN-13 format.
Implements decoding of the EAN-8 format.
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, 44 and 48 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.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Decodes PharmaCode
* @author Ruslan KarachunAttempts to decode a one-dimensional barcode format given a single row of an image.
Attempts to decode a one-dimensional barcode format given a single row of an image.
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.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Encapsulates functionality and implementation that is common to one-dimensional barcodes.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Attempts to decode a one-dimensional barcode format given a single row of an image.
Implements decoding of the UPC-A format.
Like decodeRow(int, BitArray, java.util.Map), 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.
Attempts to decode a one-dimensional barcode format given a single row of an image.
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
Encapsulates functionality and implementation that is common to UPC and EAN families of one-dimensional barcodes.
Implements decoding of the UPC-E format.
Thisis a great reference for UPC-E information.
This class contains the methods for decoding the PDF417 codewords.
PDF417 error correction implementation.
This example is quite useful in understanding the algorithm.
A field based on powers of a generator integer, modulo some modulus.
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. Checks 0, 90, 180, and 270 degree rotations.
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 reconstruct the codewords bytes contained within the QR Code.
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.
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.
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
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.
See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels defined by the QR code standard.
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
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.
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.
Encapsulates 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 an alignment pattern, which are the smaller square patterns found in all but the simplest QR Codes.
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.
This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder patterns but are smaller and appear at regular intervals throughout the image.
At the moment this only looks for the bottom-right alignment pattern.
This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, pasted and stripped down here for maximum performance but does unfortunately duplicate some code.
This class is thread-safe but not reentrant. Each thread must allocate its own object.
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.
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.
Detects a QR Code in an image.
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}.
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.
This class attempts to find finder patterns in a QR Code. Finder patterns are the square markers at three corners of a QR Code.
This class is thread-safe but not reentrant. Each thread must allocate its own object.
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.
This is called when a horizontal scan finds a possible alignment pattern. It will cross check with a vertical scan, and if successful, will, ah, cross-cross-check with another horizontal scan. This is needed primarily to locate the real horizontal center of the pattern in cases of extreme skew. And then we cross-cross-cross check with another diagonal scan.
If that succeeds the finder pattern location is added to a list that tracks the number of times each location has been nearly-matched as a finder pattern. Each additional find is more evidence that the location is in fact a finder pattern centerEncapsulates information about finder patterns in an image, including the location of the three finder patterns, and their estimated module size.
null
null
null
. This contains optional metadata about what was detected about the barcode,
like orientation.
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.List} of byte arrays corresponding to the raw bytes in the byte segments in the barcode, in order.