Ring scanner: seed the crop read, try three candidates

This commit is contained in:
2026-08-16 19:47:45 +01:00
parent c96f9b42c1
commit 1d6028715b
3 changed files with 23 additions and 11 deletions
+5 -1
View File
@@ -27,6 +27,10 @@ const pipes = {
const s = (scanners[key] ||= window.makeRingScanner({ accumulate: false }));
return s.scan(canvas, canvas.width, canvas.height, t.now ?? undefined);
},
crop: (canvas, t, key) => {
const s = (scanners[key] ||= window.makeRingScanner({ gate: t.now != null, crop: +key.slice(4) }));
return s.scan(canvas, canvas.width, canvas.height, t.now ?? undefined);
},
scan: (canvas, t, key) => {
// a lone still has no previous token to agree with
const s = (scanners[key] ||= window.makeRingScanner(t.now == null ? { gate: false } : {}));
@@ -135,7 +139,7 @@ window.runFar = async (cfg) => {
for (const name of cfg.pipes) {
for (const key of Object.keys(scanners)) delete scanners[key];
const t0 = performance.now();
const d = pipes[name](f.canvas, t, name);
const d = (pipes[name] || pipes[name.slice(0, 4)])(f.canvas, t, name);
const ms = performance.now() - t0;
res[name] = { ok: t.nocode ? !d.token : d.token === t.token, token: d.token || null, ms: +ms.toFixed(1), found: d.found, score: d.score == null ? null : +(+d.score).toFixed(2) };
}