public final class Decoder
extends java.lang.Object
The main class which implements QR Code decoding -- as opposed to locating and extracting the QR Code from an image.
Modifier and Type | Field and Description |
---|---|
private ReedSolomonDecoder |
rsDecoder |
Constructor and Description |
---|
Decoder() |
Modifier and Type | Method and Description |
---|---|
private int |
correctErrors(byte[] codewordBytes,
int numDataCodewords)
Given data and error-correction codewords received, possibly corrupted by errors, attempts to
correct the errors in-place using Reed-Solomon error correction.
|
DecoderResult |
decode(BitMatrix bits) |
DecoderResult |
decode(BitMatrix bits,
java.util.Map<DecodeHintType,?> hints)
Decodes a QR Code represented as a
BitMatrix . |
private DecoderResult |
decode(BitMatrixParser parser,
java.util.Map<DecodeHintType,?> hints) |
DecoderResult |
decode(boolean[][] image) |
DecoderResult |
decode(boolean[][] image,
java.util.Map<DecodeHintType,?> hints)
Convenience method that can decode a QR Code represented as a 2D array of booleans.
|
private final ReedSolomonDecoder rsDecoder
public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException
ChecksumException
FormatException
public DecoderResult decode(boolean[][] image, java.util.Map<DecodeHintType,?> hints) throws ChecksumException, FormatException
Convenience method that can decode a QR Code represented as a 2D array of booleans. "true" is taken to mean a black module.
image
- booleans representing white/black QR Code moduleshints
- decoding hints that should be used to influence decodingFormatException
- if the QR Code cannot be decodedChecksumException
- if error correction failspublic DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException
ChecksumException
FormatException
public DecoderResult decode(BitMatrix bits, java.util.Map<DecodeHintType,?> hints) throws FormatException, ChecksumException
Decodes a QR Code represented as a BitMatrix
. A 1 or "true" is taken to mean a black module.
bits
- booleans representing white/black QR Code moduleshints
- decoding hints that should be used to influence decodingFormatException
- if the QR Code cannot be decodedChecksumException
- if error correction failsprivate DecoderResult decode(BitMatrixParser parser, java.util.Map<DecodeHintType,?> hints) throws FormatException, ChecksumException
FormatException
ChecksumException
private int correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
codewordBytes
- data and error correction codewordsnumDataCodewords
- number of codewords that are data bytesChecksumException
- if error correction fails