AR: sub-pixel corner refinement, ROI-first detection, anchor coplanarity check

This commit is contained in:
jessikitty committed 2026-10-12 13:07:46 +11:00
1 parent 7947eb61a0
commit 7fc2b02e6a
13 files changed
+1160 -10

No files matched your search

+11
View File
@@ -21,6 +21,7 @@
*/
import * as THREE from 'three';
import { anchorWorldMatrix } from './pose.js';
import { planarity } from './geom.js';
// ---------------- marker corner templates ----------------
/* js-aruco2 corner order (canonical, matches POS-IT buildModel): TL, TR, BR, BL.
@@ -96,6 +97,7 @@ export class CvBoardSolver {
this.lastReproj = 0;
this.lastCount = 0;
this.lastReject = ''; // why the worker last refused a pose (HUD)
this.planarity = null; // anchor geometry conditioning, see geom.js
this._v = new THREE.Vector3();
this._m4 = new THREE.Matrix4();
this._q = new THREE.Quaternion();
@@ -163,6 +165,15 @@ export class CvBoardSolver {
if (a.enabled === false) continue;
this.anchors.set(a.markerId, { mat: anchorWorldMatrix(a), sizeMM: a.sizeMM || 60 });
}
/* Measure the layout's conditioning once, here, rather than discovering it
* later as intermittent mirrored poses. Warming cornersFor() for every
* anchor is a side benefit — the first solve no longer pays for it. */
const pts = [];
for (const id of this.anchors.keys()) {
const flat = this.cornersFor(id);
if (flat) pts.push(...flat);
}
this.planarity = planarity(pts);
this.filter.reset();
this.lastPose = null;
if (this.worker) this.worker.postMessage({ type: 'reset' });