Ring decoder: vanishing line search when the fit misses (screens at 30-45 deg), sync score ignores a one-sided glare; glare bench

This commit is contained in:
2026-11-16 23:18:47 +01:00
parent ef60da4349
commit b455e1644a
5 changed files with 142 additions and 12 deletions
+11
View File
@@ -76,6 +76,7 @@ function page(pw, ph, d, t, rnd) {
}
// one sensor frame. t: W H frac tilt axis dist wash cast oblur pblur motion noise band gain dx dy theta bits anim fade
// glare: [dx, dy, radius, strength 0..1, tint] around the code centre, in code diameters
// returns { canvas, truth } where truth maps code space to pixel index coordinates of the frame
export function frame(room, t, rnd) {
const { W, H } = t, ss = 2;
@@ -117,6 +118,16 @@ export function frame(room, t, rnd) {
sctx.imageSmoothingQuality = "high";
sctx.drawImage(B, x0, y0, x1 - x0, y1 - y0);
}
if (t.glare) {
// reflection of a window or lamp on the screen: a tinted bright veil over part of the code
const [gx, gy, gr, gs, tint] = t.glare, [ccx, ccy] = applyH(fwd, P.cx, P.cy);
const x = ccx + gx * d, y = ccy + gy * d, g = sctx.createRadialGradient(x, y, 0, x, y, gr * d);
const [tr, tg, tb] = tint || [255, 235, 245];
g.addColorStop(0, `rgba(${tr},${tg},${tb},${gs})`); g.addColorStop(0.5, `rgba(${tr},${tg},${tb},${gs * 0.6})`); g.addColorStop(1, `rgba(${tr},${tg},${tb},0)`);
sctx.globalCompositeOperation = "screen";
sctx.fillStyle = g; sctx.fillRect(0, 0, W, H);
sctx.globalCompositeOperation = "source-over";
}
const out = document.createElement("canvas"); out.width = W; out.height = H;
const octx = out.getContext("2d", { willReadFrequently: true });
// optical blur is angular (scales with sensor resolution), pixel softness is not