| 64 | } |
| 65 | |
| 66 | static Results DoDecode(const BinaryBitmap& image, bool multiple, bool tryRotate, bool returnErrors) |
| 67 | { |
| 68 | Detector::Result detectorResult = Detector::Detect(image, multiple, tryRotate); |
| 69 | if (detectorResult.points.empty()) |
| 70 | return {}; |
| 71 | |
| 72 | auto rotate = [res = detectorResult](PointI p) { |
| 73 | switch(res.rotation) { |
| 74 | case 90: return PointI(res.bits->height() - p.y - 1, p.x); |
| 75 | case 180: return PointI(res.bits->width() - p.x - 1, res.bits->height() - p.y - 1); |
| 76 | case 270: return PointI(p.y, res.bits->width() - p.x - 1); |
| 77 | } |
| 78 | return p; |
| 79 | }; |
| 80 | |
| 81 | Results results; |
| 82 | for (const auto& points : detectorResult.points) { |
| 83 | DecoderResult decoderResult = |
| 84 | ScanningDecoder::Decode(*detectorResult.bits, points[4], points[5], points[6], points[7], |
| 85 | GetMinCodewordWidth(points), GetMaxCodewordWidth(points)); |
| 86 | if (decoderResult.isValid(returnErrors)) { |
| 87 | auto point = [&](int i) { return rotate(PointI(points[i].value())); }; |
| 88 | Result result(std::move(decoderResult), {point(0), point(2), point(3), point(1)}, BarcodeFormat::PDF417); |
| 89 | results.push_back(result); |
| 90 | if (!multiple) |
| 91 | return results; |
| 92 | } |
| 93 | } |
| 94 | return results; |
| 95 | } |
| 96 | |
| 97 | // new implementation (only for isPure use case atm.) |
| 98 |
no test coverage detected