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

Function Scan

czxing/src/main/cpp/zxing/src/datamatrix/DMDetector.cpp:679–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677};
678
679static DetectorResult Scan(EdgeTracer& startTracer, std::array<DMRegressionLine, 4>& lines)
680{
681 while (startTracer.moveToNextWhiteAfterBlack()) {
682 log(startTracer.p);
683
684 PointF tl, bl, br, tr;
685 auto& [lineL, lineB, lineR, lineT] = lines;
686
687 for (auto& l : lines)
688 l.reset();
689
690#ifdef PRINT_DEBUG
691 SCOPE_EXIT([&] {
692 for (auto& l : lines)
693 log(l.points());
694 });
695# define CHECK(A) if (!(A)) { printf("broke at %d\n", __LINE__); continue; }
696#else
697# define CHECK(A) if(!(A)) continue
698#endif
699
700 auto t = startTracer;
701
702 // follow left leg upwards
703 t.turnRight();
704 t.state = 1;
705 CHECK(t.traceLine(t.right(), lineL));
706 CHECK(t.traceCorner(t.right(), tl));
707 lineL.reverse();
708 auto tlTracer = t;
709
710 // follow left leg downwards
711 t = startTracer;
712 t.state = 1;
713 t.setDirection(tlTracer.right());
714 CHECK(t.traceLine(t.left(), lineL));
715 if (!lineL.isValid())
716 t.updateDirectionFromOrigin(tl);
717 auto up = t.back();
718 CHECK(t.traceCorner(t.left(), bl));
719
720 // follow bottom leg right
721 t.state = 2;
722 CHECK(t.traceLine(t.left(), lineB));
723 if (!lineB.isValid())
724 t.updateDirectionFromOrigin(bl);
725 auto right = t.front();
726 CHECK(t.traceCorner(t.left(), br));
727
728 auto lenL = distance(tl, bl) - 1;
729 auto lenB = distance(bl, br) - 1;
730 CHECK(lenL >= 8 && lenB >= 10 && lenB >= lenL / 4 && lenB <= lenL * 18);
731
732 auto maxStepSize = static_cast<int>(lenB / 5 + 1); // datamatrix bottom dim is at least 10
733
734 // at this point we found a plausible L-shape and are now looking for the b/w pattern at the top and right:
735 // follow top row right 'half way' (4 gaps), see traceGaps break condition with 'invalid' line
736 tlTracer.setDirection(right);

Callers 1

DetectNewFunction · 0.85

Calls 15

distanceFunction · 0.85
intersectFunction · 0.85
normalizedFunction · 0.85
turnRightMethod · 0.80
traceLineMethod · 0.80
rightMethod · 0.80
traceCornerMethod · 0.80
leftMethod · 0.80
backMethod · 0.80

Tested by

no test coverage detected