/* detect.js — tuned ArUco 4x4 detection. * Phantom-ID fix: reject any marker decoded with hamming distance > 0 (maxHamming: 0). */ export function createDetector() { return new AR.Detector({ dictionaryName: 'ARUCO_4X4_1000', maxHammingDistance: 0 }); } export function detectMarkers(detector, imageData, knownIds) { const markers = detector.detect(imageData); // keep only markers that exist in the scene, with sane geometry return markers.filter(m => knownIds.has(m.id) && quadArea(m.corners) > 100); } export function quadArea(c) { // shoelace let a = 0; for (let i = 0; i < 4; i++) { const p = c[i], q = c[(i + 1) % 4]; a += p.x * q.y - q.x * p.y; } return Math.abs(a) / 2; }