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

Function TraceLine

czxing/src/main/cpp/zxing/src/qrcode/QRDetector.cpp:229–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229static RegressionLine TraceLine(const BitMatrix& image, PointF p, PointF d, int edge)
230{
231 BitMatrixCursorF cur(image, p, d - p);
232 RegressionLine line;
233 line.setDirectionInward(cur.back());
234
235 // collect points inside the black line -> backup on 3rd edge
236 cur.stepToEdge(edge, 0, edge == 3);
237 if (edge == 3)
238 cur.turnBack();
239
240 auto curI = BitMatrixCursorI(image, PointI(cur.p), PointI(mainDirection(cur.d)));
241 // make sure curI positioned such that the white->black edge is directly behind
242 // Test image: fix-traceline.jpg
243 while (!curI.edgeAtBack()) {
244 if (curI.edgeAtLeft())
245 curI.turnRight();
246 else if (curI.edgeAtRight())
247 curI.turnLeft();
248 else
249 curI.step(-1);
250 }
251
252 for (auto dir : {Direction::LEFT, Direction::RIGHT}) {
253 auto c = BitMatrixCursorI(image, curI.p, curI.direction(dir));
254 auto stepCount = static_cast<int>(maxAbsComponent(cur.p - p));
255 do {
256 line.add(centered(c.p));
257 } while (--stepCount > 0 && c.stepAlongEdge(dir, true));
258 }
259
260 line.evaluate(1.0, true);
261
262 for (auto p : line.points())
263 log(p, 2);
264
265 return line;
266}
267
268// estimate how tilted the symbol is (return value between 1 and 2, see also above)
269static double EstimateTilt(const FinderPatternSet& fp)

Callers 1

SampleQRFunction · 0.85

Calls 15

mainDirectionFunction · 0.85
maxAbsComponentFunction · 0.85
centeredFunction · 0.85
setDirectionInwardMethod · 0.80
backMethod · 0.80
stepToEdgeMethod · 0.80
turnBackMethod · 0.80
edgeAtBackMethod · 0.80
edgeAtLeftMethod · 0.80
turnRightMethod · 0.80
edgeAtRightMethod · 0.80
turnLeftMethod · 0.80

Tested by

no test coverage detected