| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- // config.js
- // Pure constants: landmark indices, calibration grid, parameters, connections.
- // No imports; no DOM access; no side effects.
- export const TRAIL_LENGTH = 30; // # of trail points
- export const ORB_RADIUS = 40; // px
- export const GRID_DRAW_INTERVAL_MS = 33; // ~30fps redraw
- // Kalman filter (replaces EMA + outlier threshold — Kalman handles noise naturally via R)
- // No constant needed here; see kalUpdate / kalInit below.
- // Calibration config
- export const CAL_SAMPLES_PER_POINT = 30; // samples per point (first 3 are discarded)
- export const CAL_SAMPLE_INTERVAL_MS = 50; // ms between samples
- export const CAL_MARGIN = 0.15; // 15% margin on each edge
- export const CAL_STORAGE_KEY = 'eye-tracking-calibration';
- // Bumped to 4: regression now uses 9-dim features (rX, rY, ear, pitch, yaw, rX², rY², rX*rY).
- // Old 6-coef payloads are rejected by loadCalibration() so the user re-calibrates once.
- export const CAL_VERSION = 4;
- // ---- Eye-state features (V2 model) ----
- // EAR (Eye Aspect Ratio) thresholds.
- // EAR = vertical eye-opening / horizontal eye-width.
- // An open eye is typically ~0.28–0.35; a fully closed eye is ~0.0.
- // A blink is a transient dip below ~0.22 (Soukupová & Čech, 2016).
- export const EAR_BLINK_THRESHOLD = 0.22; // < this value => blink frame; skip raw gaze update
- export const EAR_CLOSED_THRESHOLD = 0.15; // < this value => considered "eye closed"
- // ---- Head-pose feature switch ----
- // When true, the regression model includes simple geometric head-pitch / head-yaw
- // estimates (derived from nose vs. eye-corners / chin / forehead). The 9-dim
- // model below already wires them in; this flag is a documentation/extension
- // hook so we can later add features (e.g. roll) or fall back to 6-dim if needed.
- export const HEAD_POSE_FEATURES = true;
- // ---- Head-pose landmark indices (MediaPipe Face Mesh) ----
- // We use a simple geometric estimate (not full PnP). See computeHeadPose() in gaze.js.
- export const NOSE_TIP = 1; // tip of the nose
- export const CHIN = 152; // bottom of the chin
- export const FOREHEAD = 10; // top of the forehead (between brows)
- export const LEFT_EYE_CORNER = 33; // outer corner of the left eye (in raw frame)
- export const RIGHT_EYE_CORNER = 263; // outer corner of the right eye (in raw frame)
- // Iris / eye landmark indices (MediaPipe Face Mesh)
- // Left eye
- export const L_OUTER = 33, L_INNER = 133;
- export const L_TOP = 159, L_BOT = 145;
- export const L_IRIS = 468;
- // Right eye
- export const R_OUTER = 362, R_INNER = 263;
- export const R_TOP = 386, R_BOT = 374;
- export const R_IRIS = 473;
- // Iris contour points
- export const IRIS_LANDMARKS = [
- 468, 469, 470, 471, 472, // left iris
- 473, 474, 475, 476, 477 // right iris
- ];
- // Face mesh tesselation connection subsets (subset of FACE_TESSELATION)
- // Use eye / brow / lip / nose silhouettes to keep it light
- export const FACE_OVAL = [10, 338, 297, 332, 284, 251, 389, 356, 454, 323, 361, 288, 397, 365, 379, 378, 400, 377, 152, 148, 176, 149, 150, 136, 172, 58, 132, 93, 234, 127, 162, 21, 54, 103, 67, 109];
- export const LIPS = [61, 146, 91, 181, 84, 17, 314, 405, 321, 375, 291, 308, 324, 318, 402, 317, 14, 87, 178, 88, 95, 78];
- export const L_EYE = [33, 7, 163, 144, 145, 153, 154, 155, 133, 173, 157, 158, 159, 160, 161, 246];
- export const R_EYE = [362, 382, 381, 380, 374, 373, 390, 249, 263, 466, 388, 387, 386, 385, 384, 398];
- export const L_BROW = [46, 53, 52, 65, 55, 107, 66, 105, 63, 70];
- export const R_BROW = [276, 283, 282, 295, 285, 336, 296, 334, 293, 300];
- // 13-point calibration grid (center + 4 corners + 4 edges + 4 mid-diagonal)
- // The drawing is mirrored via CSS scaleX(-1), so these coords are
- // intentionally in the *displayed* (mirrored) frame of reference.
- // 5 rows × variable cols (5+3 cols) — center column used in rows 0,2,4 only.
- export const CAL_GRID = [
- // row 0 (top)
- { x: 0.1, y: 0.1 }, // TL
- { x: 0.5, y: 0.1 }, // TM
- { x: 0.9, y: 0.1 }, // TR
- // row 1 (upper mid)
- { x: 0.1, y: 0.3 }, // UL-mid
- { x: 0.9, y: 0.3 }, // UR-mid
- // row 2 (middle)
- { x: 0.1, y: 0.5 }, // ML
- { x: 0.5, y: 0.5 }, // MM (center)
- { x: 0.9, y: 0.5 }, // MR
- // row 3 (lower mid)
- { x: 0.1, y: 0.7 }, // LL-mid
- { x: 0.9, y: 0.7 }, // LR-mid
- // row 4 (bottom)
- { x: 0.1, y: 0.9 }, // BL
- { x: 0.5, y: 0.9 }, // BM
- { x: 0.9, y: 0.9 } // BR
- ];
- // Order: row-major traversal
- export const CAL_ORDER = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|