Skip to content

Commit ee252a4

Browse files
authored
fix(scanner): bring the detector back in line with Android, on matching OpenCV (#630)
1 parent 20d7240 commit ee252a4

560 files changed

Lines changed: 8730 additions & 363319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CodeScanner/CodeScanner/src/scanner.cpp‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ bool detectKikCode(Mat &greyscale, Mat *out_progress, uint32_t device_quality, u
655655
for (int j = 0; j < contour.size(); ++j) {
656656
Point2i &point = contour[j];
657657

658-
if (matches_near_ellipses.at<char>(point.y, point.x) != 0) {
658+
if (point.x >= 0 && point.y >= 0 && point.x < matches_near_ellipses.cols && point.y < matches_near_ellipses.rows
659+
&& matches_near_ellipses.at<char>(point.y, point.x) != 0) {
659660
pruned_contour.push_back(point);
660661
}
661662
}
@@ -718,7 +719,15 @@ bool detectKikCode(Mat &greyscale, Mat *out_progress, uint32_t device_quality, u
718719
float dist = sqrt(pow(center1.x - center2.x, 2)
719720
+ pow(center1.y - center2.y, 2));
720721

721-
if (dist < 50 && 2 * potential_ellipses[i].size.area() > potential_ellipses[j].size.area()) {
722+
float area1 = potential_ellipses[i].size.area();
723+
float area2 = potential_ellipses[j].size.area();
724+
725+
// Only prune true near-duplicates -- the same physical circle fitted twice from the
726+
// inner and outer edge of its stroke, which are comparable in area. A nearby ellipse
727+
// that is much smaller is a *different* feature nested inside this one (e.g. the dot
728+
// knocked out of the centre badge's glyph), and dropping the enclosing candidate in
729+
// its favour loses the only ellipse that can yield finder points.
730+
if (dist < 50 && 2 * area1 > area2 && 2 * area2 > area1) {
722731
allowed = false;
723732
break;
724733
}

‎CodeScanner/Frameworks/opencv2.xcframework.backup.20251202_202647/Info.plist‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)