Java Code Examples for com.google.zxing.common.DecoderResult#getText()

The following examples show how to use com.google.zxing.common.DecoderResult#getText() . 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 weex with Apache License 2.0 6 votes vote down vote up
@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: MaxiCodeReader.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: DataMatrixReader.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
@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 4
Source File: PDF417Reader.java    From weex with Apache License 2.0 6 votes vote down vote up
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 5
Source File: DataMatrixReader.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: PDF417Reader.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
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 7
Source File: QRCodeReader.java    From reacteu-app with MIT License 6 votes vote down vote up
@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 8
Source File: MaxiCodeReader.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
@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 9
Source File: PDF417Reader.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public Result decode(BinaryBitmap binarybitmap, Map map)
{
    DecoderResult decoderresult;
    ResultPoint aresultpoint[];
    if (map != null && map.containsKey(DecodeHintType.PURE_BARCODE))
    {
        BitMatrix bitmatrix = a(binarybitmap.getBlackMatrix());
        decoderresult = b.decode(bitmatrix);
        aresultpoint = a;
    } else
    {
        DetectorResult detectorresult = (new Detector(binarybitmap)).detect();
        decoderresult = b.decode(detectorresult.getBits());
        aresultpoint = detectorresult.getPoints();
    }
    return new Result(decoderresult.getText(), decoderresult.getRawBytes(), aresultpoint, BarcodeFormat.PDF_417);
}
 
Example 10
Source File: PDF417Reader.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
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 11
Source File: MaxiCodeReader.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
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 12
Source File: QRCodeReader.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: QRCodeReader.java    From ScreenCapture with MIT License 5 votes vote down vote up
@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 14
Source File: AztecReader.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public Result decode(BinaryBitmap binarybitmap, Map map)
{
    AztecDetectorResult aztecdetectorresult = (new Detector(binarybitmap.getBlackMatrix())).detect();
    com.google.zxing.ResultPoint aresultpoint[] = aztecdetectorresult.getPoints();
    if (map != null)
    {
        ResultPointCallback resultpointcallback = (ResultPointCallback)map.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
        if (resultpointcallback != null)
        {
            int i = aresultpoint.length;
            for (int j = 0; j < i; j++)
            {
                resultpointcallback.foundPossibleResultPoint(aresultpoint[j]);
            }

        }
    }
    DecoderResult decoderresult = (new Decoder()).decode(aztecdetectorresult);
    Result result = new Result(decoderresult.getText(), decoderresult.getRawBytes(), aresultpoint, BarcodeFormat.AZTEC);
    java.util.List list = decoderresult.getByteSegments();
    if (list != null)
    {
        result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, list);
    }
    String s = decoderresult.getECLevel();
    if (s != null)
    {
        result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, s);
    }
    return result;
}
 
Example 15
Source File: QRCodeReader.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@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 16
Source File: QRCodeMultiReader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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(EMPTY_RESULT_ARRAY);
  }
}
 
Example 17
Source File: AztecReader.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
    throws NotFoundException, FormatException {

  AztecDetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
  ResultPoint[] points = detectorResult.getPoints();

  if (hints != null) {
    ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
    if (rpcb != null) {
      for (ResultPoint point : points) {
        rpcb.foundPossibleResultPoint(point);
      }
    }
  }

  DecoderResult decoderResult = new Decoder().decode(detectorResult);

  Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.AZTEC);
  
  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: QRCodeMultiReader.java    From weex with Apache License 2.0 5 votes vote down vote up
@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 19
Source File: QRCodeMultiReader.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
  List<Result> results = new ArrayList<Result>();
  DetectorResult[] detectorResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints);
  for (DetectorResult detectorResult : detectorResults) {
    try {
      DecoderResult decoderResult = getDecoder().decode(detectorResult.getBits(), hints);
      ResultPoint[] 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);
      }
      results.add(result);
    } catch (ReaderException re) {
      // ignore and continue 
    }
  }
  if (results.isEmpty()) {
    return EMPTY_RESULT_ARRAY;
  } else {
    return results.toArray(new Result[results.size()]);
  }
}
 
Example 20
Source File: QRCodeMultiReader.java    From ScreenCapture with MIT License 5 votes vote down vote up
@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()]);
  }
}