MCPcopy Create free account
hub / github.com/devilsen/CZXing / DecodePure

Function DecodePure

czxing/src/main/cpp/zxing/src/pdf417/PDFReader.cpp:260–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258DecoderResult DecodeCodewords(std::vector<int>& codewords, int ecLevel, const std::vector<int>& erasures);
259
260static 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
308Result
309Reader::decode(const BinaryBitmap& image) const

Callers 1

decodeMethod · 0.85

Calls 14

SaveAsPBMFunction · 0.85
centeredFunction · 0.85
DetectSymbolFunction · 0.85
ReadCodeWordsFunction · 0.85
DecodeCodewordsFunction · 0.85
moveFunction · 0.85
getBitMatrixMethod · 0.80
findBoundingBoxMethod · 0.80
stepMethod · 0.80
turnRightMethod · 0.80
ResultClass · 0.70
swapFunction · 0.50

Tested by

no test coverage detected