| 258 | DecoderResult DecodeCodewords(std::vector<int>& codewords, int ecLevel, const std::vector<int>& erasures); |
| 259 | |
| 260 | static Result DecodePure(const BinaryBitmap& image_) |
| 261 | { |
| 262 | auto pimage = image_.getBitMatrix(); |
| 263 | if (!pimage) |
| 264 | return {}; |
| 265 | auto& image = *pimage; |
| 266 | |
| 267 | #ifdef PRINT_DEBUG |
| 268 | SaveAsPBM(image, "weg.pbm"); |
| 269 | #endif |
| 270 | |
| 271 | int left, top, width, height; |
| 272 | if (!image.findBoundingBox(left, top, width, height, 9) || (width < 3 * 17 && height < 3 * 17)) |
| 273 | return {}; |
| 274 | int right = left + width - 1; |
| 275 | int bottom = top + height - 1; |
| 276 | |
| 277 | // counter intuitively, using a floating point cursor is about twice as fast an integer one (on an AVX architecture) |
| 278 | BitMatrixCursorF cur(image, centered(PointI{left, top}), PointF{1, 0}); |
| 279 | SymbolInfo info; |
| 280 | |
| 281 | // try all 4 orientations |
| 282 | for (int a = 0; a < 4; ++a) { |
| 283 | info = DetectSymbol(cur, width, height); |
| 284 | if (info) |
| 285 | break; |
| 286 | cur.step(width - 1); |
| 287 | cur.turnRight(); |
| 288 | std::swap(width, height); |
| 289 | } |
| 290 | |
| 291 | if (!info) |
| 292 | return {}; |
| 293 | |
| 294 | auto codeWords = ReadCodeWords(cur, info); |
| 295 | |
| 296 | std::vector<int> erasures; |
| 297 | for (int i = 0; i < Size(codeWords); ++i) |
| 298 | if (codeWords[i] == -1) { |
| 299 | codeWords[i] = 0; |
| 300 | erasures.push_back(i); |
| 301 | } |
| 302 | |
| 303 | auto res = DecodeCodewords(codeWords, info.ecLevel, erasures); |
| 304 | |
| 305 | return Result(std::move(res), {{left, top}, {right, top}, {right, bottom}, {left, bottom}}, BarcodeFormat::PDF417); |
| 306 | } |
| 307 | |
| 308 | Result |
| 309 | Reader::decode(const BinaryBitmap& image) const |
no test coverage detected