com.google.zxing.common.DecoderResult Java Examples
The following examples show how to use
com.google.zxing.common.DecoderResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataMatrixReader.java From RipplePower with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); decoderResult = decoder.decode(detectorResult.getBits()); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.DATA_MATRIX); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #2
Source File: PDF417Reader.java From barcodescanner-lib-aar with MIT License | 6 votes |
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) throws NotFoundException, FormatException, ChecksumException { List<Result> results = new ArrayList<>(); PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple); for (ResultPoint[] points : detectorResult.getPoints()) { DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points)); Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417); result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel()); PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther(); if (pdf417ResultMetadata != null) { result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata); } results.add(result); } return results.toArray(new Result[results.size()]); }
Example #3
Source File: MaxiCodeReader.java From weex with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); } else { throw NotFoundException.getNotFoundInstance(); } ResultPoint[] points = NO_POINTS; Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.MAXICODE); String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #4
Source File: MaxiCodeReader.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public Result decode(BinaryBitmap binarybitmap, Map map) { if (map != null && map.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bitmatrix = a(binarybitmap.getBlackMatrix()); DecoderResult decoderresult = d.decode(bitmatrix, map); ResultPoint aresultpoint[] = a; Result result = new Result(decoderresult.getText(), decoderresult.getRawBytes(), aresultpoint, BarcodeFormat.MAXICODE); String s = decoderresult.getECLevel(); if (s != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, s); } return result; } else { throw NotFoundException.getNotFoundInstance(); } }
Example #5
Source File: MaxiCodeReader.java From RipplePower with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); } else { throw NotFoundException.getNotFoundInstance(); } ResultPoint[] points = NO_POINTS; Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.MAXICODE); String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #6
Source File: DataMatrixReader.java From ZXing-Orient with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); decoderResult = decoder.decode(detectorResult.getBits()); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.DATA_MATRIX); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #7
Source File: Decoder.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public DecoderResult decode(boolean aflag[][], Map map) { int i = aflag.length; BitMatrix bitmatrix = new BitMatrix(i); for (int j = 0; j < i; j++) { for (int k = 0; k < i; k++) { if (aflag[j][k]) { bitmatrix.set(k, j); } } } return decode(bitmatrix, map); }
Example #8
Source File: DataMatrixReader.java From reacteu-app with MIT License | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); decoderResult = decoder.decode(detectorResult.getBits()); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.DATA_MATRIX); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #9
Source File: QRCodeReader.java From barterli_android with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints); decoderResult = decoder.decode(detectorResult.getBits(), hints); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #10
Source File: PDF417ScanningDecoder.java From barcodescanner-lib-aar with MIT License | 6 votes |
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException, ChecksumException { if (codewords.length == 0) { throw FormatException.getFormatInstance(); } int numECCodewords = 1 << (ecLevel + 1); int correctedErrorsCount = correctErrors(codewords, erasures, numECCodewords); verifyCodewordCount(codewords, numECCodewords); // Decode the codewords DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel)); decoderResult.setErrorsCorrected(correctedErrorsCount); decoderResult.setErasures(erasures.length); return decoderResult; }
Example #11
Source File: QRCodeReader.java From android-quick-response-code with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints); decoderResult = decoder.decode(detectorResult.getBits(), hints); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #12
Source File: PDF417Reader.java From reacteu-app with MIT License | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, FormatException, ChecksumException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image).detect(); decoderResult = decoder.decode(detectorResult.getBits()); points = detectorResult.getPoints(); } return new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417); }
Example #13
Source File: PDF417Reader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) throws NotFoundException, FormatException, ChecksumException { List<Result> results = new ArrayList<>(); PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple); for (ResultPoint[] points : detectorResult.getPoints()) { DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points)); Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417); result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel()); PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther(); if (pdf417ResultMetadata != null) { result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata); } results.add(result); } return results.toArray(new Result[results.size()]); }
Example #14
Source File: PDF417ScanningDecoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException, ChecksumException { if (codewords.length == 0) { throw FormatException.getFormatInstance(); } int numECCodewords = 1 << (ecLevel + 1); int correctedErrorsCount = correctErrors(codewords, erasures, numECCodewords); verifyCodewordCount(codewords, numECCodewords); // Decode the codewords DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel)); decoderResult.setErrorsCorrected(correctedErrorsCount); decoderResult.setErasures(erasures.length); return decoderResult; }
Example #15
Source File: PDF417ScanningDecoder.java From weex with Apache License 2.0 | 6 votes |
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException, ChecksumException { if (codewords.length == 0) { throw FormatException.getFormatInstance(); } int numECCodewords = 1 << (ecLevel + 1); int correctedErrorsCount = correctErrors(codewords, erasures, numECCodewords); verifyCodewordCount(codewords, numECCodewords); // Decode the codewords DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel)); decoderResult.setErrorsCorrected(correctedErrorsCount); decoderResult.setErasures(erasures.length); return decoderResult; }
Example #16
Source File: DataMatrixReader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); decoderResult = decoder.decode(detectorResult.getBits()); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.DATA_MATRIX); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #17
Source File: QRCodeReader.java From reacteu-app with MIT License | 6 votes |
@Override public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints); decoderResult = decoder.decode(detectorResult.getBits(), hints); points = detectorResult.getPoints(); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } return result; }
Example #18
Source File: Decoder.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public DecoderResult decode(boolean aflag[][]) { int i = aflag.length; BitMatrix bitmatrix = new BitMatrix(i); for (int j = 0; j < i; j++) { for (int k = 0; k < i; k++) { if (aflag[j][k]) { bitmatrix.set(k, j); } } } return decode(bitmatrix); }
Example #19
Source File: PDF417Reader.java From weex with Apache License 2.0 | 6 votes |
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) throws NotFoundException, FormatException, ChecksumException { List<Result> results = new ArrayList<>(); PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple); for (ResultPoint[] points : detectorResult.getPoints()) { DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points)); Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417); result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel()); PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther(); if (pdf417ResultMetadata != null) { result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata); } results.add(result); } return results.toArray(new Result[results.size()]); }
Example #20
Source File: Decoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
/** * <p>Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken * to mean a black module.</p> * * @param bits booleans representing white/black Data Matrix Code modules * @return text and bytes encoded within the Data Matrix Code * @throws FormatException if the Data Matrix Code cannot be decoded * @throws ChecksumException if error correction fails */ public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { // Construct a parser and read version, error-correction level BitMatrixParser parser = new BitMatrixParser(bits); Version version = parser.getVersion(); // Read codewords byte[] codewords = parser.readCodewords(); // Separate into data blocks DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version); int dataBlocksCount = dataBlocks.length; // Count total number of data bytes int totalBytes = 0; for (DataBlock db : dataBlocks) { totalBytes += db.getNumDataCodewords(); } byte[] resultBytes = new byte[totalBytes]; // Error-correct and copy data blocks together into a stream of bytes for (int j = 0; j < dataBlocksCount; j++) { DataBlock dataBlock = dataBlocks[j]; byte[] codewordBytes = dataBlock.getCodewords(); int numDataCodewords = dataBlock.getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { // De-interlace data blocks. resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; } } // Decode the contents of that stream of bytes return DecodedBitStreamParser.decode(resultBytes); }
Example #21
Source File: DecodedBitStreamParser.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
static DecoderResult decode(byte[] bytes, int mode) { StringBuilder result = new StringBuilder(144); switch (mode) { case 2: case 3: String postcode; if (mode == 2) { int pc = getPostCode2(bytes); NumberFormat df = new DecimalFormat("0000000000".substring(0, getPostCode2Length(bytes))); postcode = df.format(pc); } else { postcode = getPostCode3(bytes); } String country = THREE_DIGITS.format(getCountry(bytes)); String service = THREE_DIGITS.format(getServiceClass(bytes)); result.append(getMessage(bytes, 10, 84)); if (result.toString().startsWith("[)>"+RS+"01"+GS)) { result.insert(9, postcode + GS + country + GS + service + GS); } else { result.insert(0, postcode + GS + country + GS + service + GS); } break; case 4: result.append(getMessage(bytes, 1, 93)); break; case 5: result.append(getMessage(bytes, 1, 77)); break; } return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode)); }
Example #22
Source File: Decoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
public DecoderResult decode(BitMatrix bits, Map<DecodeHintType,?> hints) throws FormatException, ChecksumException { BitMatrixParser parser = new BitMatrixParser(bits); byte[] codewords = parser.readCodewords(); correctErrors(codewords, 0, 10, 10, ALL); int mode = codewords[0] & 0x0F; byte[] datawords; switch (mode) { case 2: case 3: case 4: correctErrors(codewords, 20, 84, 40, EVEN); correctErrors(codewords, 20, 84, 40, ODD); datawords = new byte[94]; break; case 5: correctErrors(codewords, 20, 68, 56, EVEN); correctErrors(codewords, 20, 68, 56, ODD); datawords = new byte[78]; break; default: throw FormatException.getFormatInstance(); } System.arraycopy(codewords, 0, datawords, 0, 10); System.arraycopy(codewords, 20, datawords, 10, datawords.length - 10); return DecodedBitStreamParser.decode(datawords, mode); }
Example #23
Source File: QRCodeReader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
@Override public final Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, ChecksumException, FormatException { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits, hints); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints); decoderResult = decoder.decode(detectorResult.getBits(), hints); points = detectorResult.getPoints(); } // If the code was mirrored: swap the bottom-left and the top-right points. if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) { ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } if (decoderResult.hasStructuredAppend()) { result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber()); result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity()); } return result; }
Example #24
Source File: DecodedBitStreamParser.java From barcodescanner-lib-aar with MIT License | 5 votes |
static DecoderResult decode(byte[] bytes, int mode) { StringBuilder result = new StringBuilder(144); switch (mode) { case 2: case 3: String postcode; if (mode == 2) { int pc = getPostCode2(bytes); NumberFormat df = new DecimalFormat("0000000000".substring(0, getPostCode2Length(bytes))); postcode = df.format(pc); } else { postcode = getPostCode3(bytes); } NumberFormat threeDigits = new DecimalFormat("000"); String country = threeDigits.format(getCountry(bytes)); String service = threeDigits.format(getServiceClass(bytes)); result.append(getMessage(bytes, 10, 84)); if (result.toString().startsWith("[)>" + RS + "01" + GS)) { result.insert(9, postcode + GS + country + GS + service + GS); } else { result.insert(0, postcode + GS + country + GS + service + GS); } break; case 4: result.append(getMessage(bytes, 1, 93)); break; case 5: result.append(getMessage(bytes, 1, 77)); break; } return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode)); }
Example #25
Source File: Decoder.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public DecoderResult decode(BitMatrix bitmatrix) { a a1 = new a(bitmatrix); int ai[] = a1.a(); if (ai.length == 0) { throw FormatException.getFormatInstance(); } else { int i = 1 << 1 + a1.c(); a(ai, a1.b(), i); a(ai, i); return com.google.zxing.pdf417.decoder.b.a(ai); } }
Example #26
Source File: PDF417ScanningDecoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
private static DecoderResult createDecoderResult(DetectionResult detectionResult) throws FormatException, ChecksumException, NotFoundException { BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionResult); adjustCodewordCount(detectionResult, barcodeMatrix); Collection<Integer> erasures = new ArrayList<>(); int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()]; List<int[]> ambiguousIndexValuesList = new ArrayList<>(); List<Integer> ambiguousIndexesList = new ArrayList<>(); for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) { for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) { int[] values = barcodeMatrix[row][column + 1].getValue(); int codewordIndex = row * detectionResult.getBarcodeColumnCount() + column; if (values.length == 0) { erasures.add(codewordIndex); } else if (values.length == 1) { codewords[codewordIndex] = values[0]; } else { ambiguousIndexesList.add(codewordIndex); ambiguousIndexValuesList.add(values); } } } int[][] ambiguousIndexValues = new int[ambiguousIndexValuesList.size()][]; for (int i = 0; i < ambiguousIndexValues.length; i++) { ambiguousIndexValues[i] = ambiguousIndexValuesList.get(i); } return createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords, PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues); }
Example #27
Source File: QRCodeMultiReader.java From ZXing-Orient with Apache License 2.0 | 5 votes |
@Override public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException { List<Result> results = new ArrayList<>(); DetectorResult[] detectorResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints); for (DetectorResult detectorResult : detectorResults) { try { DecoderResult decoderResult = getDecoder().decode(detectorResult.getBits(), hints); ResultPoint[] points = detectorResult.getPoints(); // If the code was mirrored: swap the bottom-left and the top-right points. if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) { ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points); } Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE); List<byte[]> byteSegments = decoderResult.getByteSegments(); if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } String ecLevel = decoderResult.getECLevel(); if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } if (decoderResult.hasStructuredAppend()) { result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber()); result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity()); } results.add(result); } catch (ReaderException re) { // ignore and continue } } if (results.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { results = processStructuredAppend(results); return results.toArray(new Result[results.size()]); } }
Example #28
Source File: Decoder.java From ZXing-Orient with Apache License 2.0 | 5 votes |
public DecoderResult decode(BitMatrix bits, Map<DecodeHintType,?> hints) throws FormatException, ChecksumException { BitMatrixParser parser = new BitMatrixParser(bits); byte[] codewords = parser.readCodewords(); correctErrors(codewords, 0, 10, 10, ALL); int mode = codewords[0] & 0x0F; byte[] datawords; switch (mode) { case 2: case 3: case 4: correctErrors(codewords, 20, 84, 40, EVEN); correctErrors(codewords, 20, 84, 40, ODD); datawords = new byte[94]; break; case 5: correctErrors(codewords, 20, 68, 56, EVEN); correctErrors(codewords, 20, 68, 56, ODD); datawords = new byte[78]; break; default: throw FormatException.getFormatInstance(); } System.arraycopy(codewords, 0, datawords, 0, 10); System.arraycopy(codewords, 20, datawords, 10, datawords.length - 10); return DecodedBitStreamParser.decode(datawords, mode); }
Example #29
Source File: DecodedBitStreamParser.java From RipplePower with Apache License 2.0 | 5 votes |
static DecoderResult decode(byte[] bytes, int mode) { StringBuilder result = new StringBuilder(144); switch (mode) { case 2: case 3: String postcode; if (mode == 2) { int pc = getPostCode2(bytes); NumberFormat df = new DecimalFormat("0000000000".substring(0, getPostCode2Length(bytes))); postcode = df.format(pc); } else { postcode = getPostCode3(bytes); } String country = THREE_DIGITS.format(getCountry(bytes)); String service = THREE_DIGITS.format(getServiceClass(bytes)); result.append(getMessage(bytes, 10, 84)); if (result.toString().startsWith("[)>" + RS + "01" + GS)) { result.insert(9, postcode + GS + country + GS + service + GS); } else { result.insert(0, postcode + GS + country + GS + service + GS); } break; case 4: result.append(getMessage(bytes, 1, 93)); break; case 5: result.append(getMessage(bytes, 1, 77)); break; } return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode)); }
Example #30
Source File: Decoder.java From reacteu-app with MIT License | 5 votes |
/** * <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. * "true" is taken to mean a black module.</p> * * @param image booleans representing white/black Data Matrix Code modules * @return text and bytes encoded within the Data Matrix Code * @throws FormatException if the Data Matrix Code cannot be decoded * @throws ChecksumException if error correction fails */ public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { int dimension = image.length; BitMatrix bits = new BitMatrix(dimension); for (int i = 0; i < dimension; i++) { for (int j = 0; j < dimension; j++) { if (image[i][j]) { bits.set(j, i); } } } return decode(bits); }