/// <summary> /// Decodes the multiple. /// </summary> /// <param name="image">The image.</param> /// <param name="hints">The hints.</param> /// <returns></returns> public Result[] decodeMultiple(BinaryBitmap image, IDictionary <DecodeHintType, object> hints) { var results = new List <Result>(); var detectorResults = new MultiDetector(image.BlackMatrix).detectMulti(hints); foreach (DetectorResult detectorResult in detectorResults) { var decoderResult = getDecoder().decode(detectorResult.Bits, hints); if (decoderResult == null) { continue; } var points = detectorResult.Points; var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE); var byteSegments = decoderResult.ByteSegments; if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } var ecLevel = decoderResult.ECLevel; if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } results.Add(result); } return(results.Count == 0 ? EMPTY_RESULT_ARRAY : results.ToArray()); }
/// <summary> /// Decodes the multiple. /// </summary> /// <param name="image">The image.</param> /// <param name="hints">The hints.</param> /// <returns></returns> public Result[] decodeMultiple(BinaryBitmap image, IDictionary <DecodeHintType, object> hints) { var results = new List <Result>(); var detectorResults = new MultiDetector(image.BlackMatrix).detectMulti(hints); foreach (DetectorResult detectorResult in detectorResults) { var decoderResult = getDecoder().decode(detectorResult.Bits, hints); if (decoderResult == null) { continue; } var points = detectorResult.Points; // If the code was mirrored: swap the bottom-left and the top-right points. var data = decoderResult.Other as QRCodeDecoderMetaData; if (data != null) { data.applyMirroredCorrection(points); } var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE); var byteSegments = decoderResult.ByteSegments; if (byteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); } var ecLevel = decoderResult.ECLevel; if (ecLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); } if (decoderResult.StructuredAppend) { result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, decoderResult.StructuredAppendSequenceNumber); result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, decoderResult.StructuredAppendParity); } results.Add(result); } if (results.Count == 0) { return(null); } results = ProcessStructuredAppend(results); return(results.ToArray()); }
public Result[] decodeMultiple(BinaryBitmap image, Dictionary<DecodeHintType, Object> hints) { var results = new List<Result>(10); DetectorResult[] detectorResult = new MultiDetector(image.BlackMatrix).detectMulti(hints); foreach (DetectorResult t in detectorResult) { try { DecoderResult decoderResult = Decoder.decode(t.Bits); ResultPoint[] points = t.Points; var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE); if (decoderResult.ByteSegments != null) { result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments); } if (decoderResult.ECLevel != null) { result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString()); } results.Add(result); } catch (ReaderException) { // ignore and continue } } if ((results.Count == 0)) { return EMPTY_RESULT_ARRAY; } var resultArray = new Result[results.Count]; for (int i = 0; i < results.Count; i++) { resultArray[i] = (Result) results[i]; } return resultArray; }