Repository navigation
Commit c4c43f8
appclip: camera detection of printed App Clip Codes
Ports the reference raster scanner (rs/appclipcode) to a grayscale
GrayFrame pipeline stage, wired into pipeline::scan_2d:
- Sobel edge field; strong edges keep their unit normals
- ring Hough: edge pixels vote along +-normal at each of the 11 expected
ring-edge radii over an outer-radius sweep (on a <=320px copy), peaks
hill-climbed at full resolution on an edge-vs-quiet-zone circle score
- affine/tilt estimate from the outer-circle edge cloud's second moments,
refined by coordinate descent over centre, angle and both axis scales
- rotation search (the code has no fiducial): every 1 degree scored by the
Otsu separability of per-position boundary contrast, best peaks refined
to 0.1 degree
- bit recovery: gap/arc from thresholded contrast (Otsu + a sweep of
plausible visible counts), 2-means over arc luminance for the
foreground/third bit in both polarities, template-byte distance ordering
attempts, Reed-Solomon arbitrating every one — first surviving URL wins
The port is deliberately color-blind: every Apple palette separates the
three colors by >=50/255 luminance, so grayscale sampling loses nothing.
One upstream deviation, deliberate: the Go scanner inserts a synthetic
separator bit and expects arc colors to start at ring bit 129 — consistent
only with its own synthetic-test renderer. Apple's actual generator (and
our SVG renderer, byte-verified against Apple fixtures) burns the
separator as the first visible arc's color, so the reconstruction here
appends sampled colors directly after the 128 gap bits.
Covered by generate -> rasterize -> scan round-trips (multiple sizes and
rotations, off-centre, gray surround), a scan_2d pipeline test, and a
no-circle rejection test; ANYD_APPCLIP_DEBUG dumps candidates and rotation
hypotheses. Busy no-circle crops cost ~100ms native / ~240ms wasm extra in
scan_all — same order as the QR fallback ladder and bounded by the
4-candidate cap; linear crops (decode1d) are unaffected.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent b306eb8 commit c4c43f8
5 files changed
Lines changed: 1204 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
0 commit comments