Skip to content

fix(scanner): stop the badge glyph dot from stealing the centre ellipse - #1306

Merged
bmc08gt merged 1 commit into
fix/scanner-luminance-fast-pathfrom
fix/scanner-badge-dot-candidate-prune
Aug 22, 2026
Merged

fix(scanner): stop the badge glyph dot from stealing the centre ellipse#1306
bmc08gt merged 1 commit into
fix/scanner-luminance-fast-pathfrom
fix/scanner-badge-dot-candidate-prune

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1303 — it needs the sweep harness that PR adds. Retarget to code/cash once #1303 lands.

The bug

A code is located by its centre badge. The badge is a disc with the Flipcash "F" knocked out of it (ic_logo_round_white, fillType="evenOdd"), and the glyph's round dot is itself a near-perfect ellipse sitting ~0.08·D from the badge centre.

Once the code is drawn large enough in frame, that dot clears the candidate filters and lands in the same 50px prune bucket as the badge. The prune then drops the wrong one:

if (dist < 50 && 2 * potential_ellipses[i].size.area() > potential_ellipses[j].size.area())

It only scans forward (j > i), so for a big/small pair it always discards the big one. The badge disappears and the search runs from the dot, which yields one finder point instead of nine.

Trace from the instrumented detector on a 1920x1080 frame:

540px code:  potential=1  candidates=1  cand0 centre=(479,269) size=85  -> 9 finder points, decoded
972px code:  potential=2  candidates=1  cand0 centre=(464,303) size=25  -> 1 finder point,  reject

size=25 at an offset down-left of centre is the glyph dot, not the badge.

This is a hard failure band, not a slowdown: hold the phone close enough and the code will not decode until you back off. It is very likely the real story behind the reports of "occasionally-slow" scanning.

The fix

Prune only true near-duplicates — the same physical circle fitted twice from the inner and outer edge of its stroke, which are comparable in area. A much smaller neighbour is a different feature nested inside, so keep both and let the search decide.

The badge sorts first and still hits on iteration 0, so the happy path is unchanged — the trace confirms the dot is never even searched.

Harness change

The sweep substituted a plain white oval for the badge, which has no glyph and therefore no dot. That is exactly why it never caught this. It now renders the real artwork.

Measured on an S25 Ultra, real ic_logo_round_white in a 1920x1080 frame:

badge 540 756 972
solid oval (old harness) pass pass pass
real logo, before pass fail fail
real logo, after pass pass pass

Full sweep with the real badge: 18/18 decoded, stride parity intact.

iOS

The same defect is live on iOS — CodeScanner/CodeScanner/src/scanner.cpp:721 carries the identical line and CodeView fills the badge with FillStyle(eoFill: true). Being ported alongside a wider scanner-parity pass.

…ipse

A code is located by its centre badge, but the badge is a disc with the
Flipcash "F" knocked out of it, and the glyph's round dot is itself a
near-perfect ellipse sitting ~0.08D from the badge centre. Once the code
is drawn large enough in frame, that dot clears the candidate filters and
the two ellipses end up in the same prune bucket.

The prune dropped the wrong one. Its rule was "discard this candidate if a
nearby one is at most twice its area", which is order-dependent and, for a
big/small pair, always discards the big one. The badge disappeared and the
scan was left searching from the dot, which yields one finder point instead
of nine. Measured on a 1920x1080 frame: a code occupying 540px decodes, 756
and 972 do not.

Prune only true near-duplicates -- the same physical circle fitted twice
from the inner and outer edge of its stroke, which are comparable in area.
A much smaller neighbour is a different feature nested inside, so keep both
and let the search decide; the badge sorts first and still hits on the first
iteration, so the happy path is unchanged.

The sweep harness masked this by substituting a plain white oval for the
badge. It now renders the real artwork, which is what put the dot in frame
in the first place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: scanner QR/Kikcode scanning, camera type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant