Vote page: remember the zoom that read the ring for the next scans, quicker zoom search
This commit is contained in:
+11
-5
@@ -118,7 +118,10 @@ function makeScanner(video, onToken, onOther) {
|
|||||||
track.applyConstraints({ advanced: [{ zoom: z }] }).catch(() => { zs = null; zoom.hidden = true; });
|
track.applyConstraints({ advanced: [{ zoom: z }] }).catch(() => { zs = null; zoom.hidden = true; });
|
||||||
}
|
}
|
||||||
function steer(d, now) {
|
function steer(d, now) {
|
||||||
if (!zs || !zs.auto) return;
|
if (!zs) return;
|
||||||
|
// people keep their seat between votes: the zoom that read the ring is where the next scan starts
|
||||||
|
if (d.token) lsSet(ZOOM_KEY, String(zs.now));
|
||||||
|
if (!zs.auto) return;
|
||||||
const z = zoomPlan(zs, d, now);
|
const z = zoomPlan(zs, d, now);
|
||||||
if (z != null) setZoom(z);
|
if (z != null) setZoom(z);
|
||||||
}
|
}
|
||||||
@@ -133,6 +136,8 @@ function makeScanner(video, onToken, onOther) {
|
|||||||
zoom.textContent = "1×";
|
zoom.textContent = "1×";
|
||||||
video.srcObject = s;
|
video.srcObject = s;
|
||||||
await video.play();
|
await video.play();
|
||||||
|
const saved = +lsGet(ZOOM_KEY);
|
||||||
|
if (zs && saved > zs.base) setZoom(Math.min(zs.max, saved));
|
||||||
}
|
}
|
||||||
zoom.onclick = () => {
|
zoom.onclick = () => {
|
||||||
if (!zs) return;
|
if (!zs) return;
|
||||||
@@ -191,19 +196,19 @@ function zoomPlan(zs, d, now) {
|
|||||||
// a zoom too many costs nothing, so a weak sync ring is enough to steer on
|
// a zoom too many costs nothing, so a weak sync ring is enough to steer on
|
||||||
const w = d.where, seen = !!w && (d.score ?? 0) >= 0.4;
|
const w = d.where, seen = !!w && (d.score ?? 0) >= 0.4;
|
||||||
if (seen) zs.lastSeen = now;
|
if (seen) zs.lastSeen = now;
|
||||||
if (now - zs.lastMove < 900) return null;
|
if (now - zs.lastMove < 600) return null;
|
||||||
let z = null;
|
let z = null;
|
||||||
if (seen && !d.token && now - zs.lastRead > 1200 && w.d < 0.24 && zs.now < zs.max) {
|
if (seen && !d.token && now - zs.lastRead > 900 && w.d < 0.24 && zs.now < zs.max) {
|
||||||
const off = Math.max(Math.abs(w.x - 0.5), Math.abs(w.y - 0.5));
|
const off = Math.max(Math.abs(w.x - 0.5), Math.abs(w.y - 0.5));
|
||||||
const fit = (zs.now * 0.45) / (off + w.d / 2);
|
const fit = (zs.now * 0.45) / (off + w.d / 2);
|
||||||
z = Math.min(zs.max, fit, zs.now * Math.min(2, 0.4 / w.d));
|
z = Math.min(zs.max, fit, zs.now * Math.min(2, 0.4 / w.d));
|
||||||
if (z < zs.now + 0.15) z = null;
|
if (z < zs.now + 0.15) z = null;
|
||||||
} else if (seen && w.d > 0.8 && zs.now > zs.base) {
|
} else if (seen && w.d > 0.8 && zs.now > zs.base) {
|
||||||
z = Math.max(zs.base, zs.now * 0.6);
|
z = Math.max(zs.base, zs.now * 0.6);
|
||||||
} else if (!seen && now - zs.lastSeen > 2500 && zs.now > zs.base) {
|
} else if (!seen && now - zs.lastSeen > 1800 && zs.now > zs.base) {
|
||||||
z = zs.base;
|
z = zs.base;
|
||||||
zs.lastSeen = now;
|
zs.lastSeen = now;
|
||||||
} else if (!seen && zs.now === zs.base && now - zs.lastSeen > 1500 && now - zs.lastMove > 1500) {
|
} else if (!seen && zs.now === zs.base && now - zs.lastSeen > 800 && now - zs.lastMove > 800) {
|
||||||
// from the back rows the ring is too small to be found at all: look closer where the person aims, the
|
// from the back rows the ring is too small to be found at all: look closer where the person aims, the
|
||||||
// middle, and fall back to wide again (branch above) when nothing shows up there either
|
// middle, and fall back to wide again (branch above) when nothing shows up there either
|
||||||
z = Math.min(zs.max, zs.base * 2);
|
z = Math.min(zs.max, zs.base * 2);
|
||||||
@@ -214,6 +219,7 @@ function zoomPlan(zs, d, now) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CAM_KEY = "rv_cam";
|
const CAM_KEY = "rv_cam";
|
||||||
|
const ZOOM_KEY = `rv_zoom_${pid}`;
|
||||||
const FRONT = /front|user|avant|facetime|selfie/i, ODD = /ultra|wide|grand.angle|macro|tele|télé|depth|infra|dual|triple|double/i, BACK = /back|rear|arri[eè]re|environment/i;
|
const FRONT = /front|user|avant|facetime|selfie/i, ODD = /ultra|wide|grand.angle|macro|tele|télé|depth|infra|dual|triple|double/i, BACK = /back|rear|arri[eè]re|environment/i;
|
||||||
|
|
||||||
function openCamera(deviceId) {
|
function openCamera(deviceId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user