wip
This commit is contained in:
@@ -25,11 +25,12 @@ const pipes = {
|
||||
native: (canvas, t) => decodeFrame(grab(canvas, 1e9).img, t.opts || {}),
|
||||
noacc: (canvas, t, key) => {
|
||||
const s = (scanners[key] ||= window.makeRingScanner({ accumulate: false }));
|
||||
return s.scan(canvas, canvas.width, canvas.height, t.now ?? null);
|
||||
return s.scan(canvas, canvas.width, canvas.height, t.now ?? undefined);
|
||||
},
|
||||
scan: (canvas, t, key) => {
|
||||
const s = (scanners[key] ||= window.makeRingScanner(t.scanOpts || {}));
|
||||
return s.scan(canvas, canvas.width, canvas.height, t.now ?? null);
|
||||
// a lone still has no previous token to agree with
|
||||
const s = (scanners[key] ||= window.makeRingScanner(t.now == null ? { gate: false } : {}));
|
||||
return s.scan(canvas, canvas.width, canvas.height, t.now ?? undefined);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { decodeFrame, grayOf } from "/static/js/ringcode.js";
|
||||
import { makeRingScanner } from "/static/js/ringscan.js";
|
||||
|
||||
const rings = makeRingScanner();
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const video = $("v"), canvas = document.createElement("canvas"), ctx = canvas.getContext("2d", { willReadFrequently: true });
|
||||
@@ -26,15 +28,14 @@ async function start() {
|
||||
async function loop() {
|
||||
if (!running) return;
|
||||
if (video.readyState >= 2) {
|
||||
// 960 px is plenty for the locator and keeps capture cheap on low-end phones
|
||||
// the qr reference reads a 960 px copy, the rings read their own crop of the full frame
|
||||
const k = Math.min(1, 960 / video.videoWidth);
|
||||
canvas.width = Math.round(video.videoWidth * k);
|
||||
canvas.height = Math.round(video.videoHeight * k);
|
||||
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
frames++; fpsN++;
|
||||
const img = grayOf(ctx.getImageData(0, 0, canvas.width, canvas.height));
|
||||
const d = decodeFrame(img);
|
||||
if (d.found) qr++;
|
||||
const d = rings.scan(video, video.videoWidth, video.videoHeight);
|
||||
if (d.cand) qr++;
|
||||
if (d.token) { ring++; mode = "anneaux"; tokens.add(d.token); }
|
||||
else if (mode !== "anneaux") {
|
||||
// reference mode: the classic rotating qr
|
||||
|
||||
Reference in New Issue
Block a user