Ref<Result> PDF417Reader::decode(Ref<BinaryBitmap> image, DecodeHints hints) { Ref<DecoderResult> decoderResult; /* 2012-05-30 hfn C++ DecodeHintType does not yet know a type "PURE_BARCODE", */ /* therefore skip this for now, todo: may be add this type later */ /* if (!hints.isEmpty() && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { */ Detector detector(image); Ref<DetectorResult> detectorResult = detector.detect(hints); /* 2012-09-17 hints ("try_harder") */ ArrayRef< Ref<ResultPoint> > points(detectorResult->getPoints()); if (!hints.isEmpty()) { Ref<ResultPointCallback> rpcb = hints.getResultPointCallback(); /* .get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); */ if (rpcb != NULL) { for (int i = 0; i < points->size(); i++) { rpcb->foundPossibleResultPoint(*points[i]); } } } decoderResult = decoder.decode(detectorResult->getBits(),hints); /* } */ Ref<Result> r(new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::PDF_417)); return r; }
Ref<Result> PDF417Reader::decode(Ref<BinaryBitmap> image, DecodeHints hints) { Ref<DecoderResult> decoderResult; /* 2012-05-30 hfn C++ DecodeHintType does not yet know a type "PURE_BARCODE", */ /* therefore skip this for now, todo: may be add this type later */ /* if (!hints.isEmpty() && hints.containsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image.getBlackMatrix()); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { */ Detector detector(image); Ref<DetectorResult> detectorResult = detector.detect(); #if (defined _WIN32 && defined DEBUG) { WCHAR sz[256]; wsprintf(sz,L"PDF417Reader::decode: detected, %d\n",detectorResult->getPoints()[0]); OutputDebugString(sz); } #endif ArrayRef< Ref<ResultPoint> > points(detectorResult->getPoints()); if (!hints.isEmpty()) { Ref<ResultPointCallback> rpcb = hints.getResultPointCallback(); /* .get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); */ if (rpcb != NULL) { for (int i = 0; i < (int)points->size(); i++) { rpcb->foundPossibleResultPoint(*(points[i])); } } } decoderResult = decoder_.decode(detectorResult->getBits()); /* } */ Ref<Result> r(new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::PDF_417)); #if (defined _WIN32 && defined(DEBUG)) { WCHAR sz[1024]; wsprintf(sz,L"PDF417Reader::decode: \"%S\"\n",decoderResult->getText().object_->getText().c_str()); OutputDebugString(sz); } #endif fprintf( stdout, "PDF417Reader::decode: \"%s\"\n", decoderResult->getText().object_->getText().c_str()); return r; }
std::vector<Ref<DetectorResult> > MultiDetector::detectMulti(DecodeHints hints){ Ref<BitMatrix> image = getImage(); MultiFinderPatternFinder finder = MultiFinderPatternFinder(image, hints.getResultPointCallback()); std::vector<Ref<FinderPatternInfo> > info = finder.findMulti(hints); std::vector<Ref<DetectorResult> > result; for(unsigned int i = 0; i < info.size(); i++){ try{ result.push_back(processFinderPatternInfo(info[i])); } catch (ReaderException const& e){ (void)e; // ignore } } return result; }
Ref<DetectorResult> Detector::detect(DecodeHints const& hints) { callback_ = hints.getResultPointCallback(); FinderPatternFinder finder(image_, hints.getResultPointCallback()); Ref<FinderPatternInfo> info(finder.find(hints)); return processFinderPatternInfo(info); }