Phase 1 — Discovery. Cast 100–300 random lines across the canvas. For each line, sample grayscale values, compute gradients, and find dense runs of 20+ regularly-spaced edges. That's a barcode signature. A single line can return multiple runs, handling aligned barcodes.
Clustering — DBSCAN. Take the midpoints of all hits and cluster them by proximity using BFS. Each cluster of 5+ hits represents a separate barcode. Barcode count is discovered, not given.
Phase 2 — Sweep. For each cluster, sweep 180 lines through its center at 1° increments. Hits near the center are collected, densifying the hit set for angle estimation and producing the visual cone pattern.
Angle — Circular Mean. For each cluster, estimate orientation using the doubled-angle trick: double each hit's direction angle (to resolve 180° ambiguity), take the score-weighted mean of sin/cos, then halve. Hit density peaks perpendicular to the bars, so the circular mean finds the correct angle.
Edge Detection (per line): sample grayscale → gradient → reject if contrast < 60 → find edge positions (local maxima, ≥2px apart) → find dense runs (gaps ≤ 5% of length) → validate: ≥20 edges, ≥40px span, ≥2px pitch, ≥60% gap regularity.
Overlays: Red = scan lines that hit a barcode. Yellow = sweep-based angle estimate. Green = cone angle (circular mean) — the primary result.
Other: Double-buffered canvases (detection reads clean pixels, never overlays). WebGPU compute shader runs the same edge detection in parallel. CPU fallback during rotation drag. Drop or paste images to test real barcodes.