Sfoglia il codice sorgente

优化眼控追踪算法:修复右眼ratioX翻转、Kalman滤波器、fallback映射

核心改动:
- 恢复右眼 ratioX 的 1- 翻转,修复两眼信号抵消问题
- 左右眼公式参考点不同导致ratioX方向相反,必须翻转才能叠加
- Kalman滤波器:修复S矩阵计算、P更新索引、Q矩阵对称性、P对称化
- fallback映射:rawX加上0.5偏移,看正前方时光标居中而非卡在左侧
- 去掉EMA改用Kalman 4维状态[x,y,vx,vy]
- 二次多项式回归替代线性回归,6维特征solve6x6
- 13点校准网格、RANSAC异常值剔除、丢弃前3帧
- ratioY改用eyeW归一化(不受眨眼影响)
- 性能优化:去掉radialGradient和shadowBlur
- iris 5点contour平均降低噪声
- CAL_VERSION版本门控,旧校准数据自动失效
root 5 mesi fa
parent
commit
63826fb81a
4 ha cambiato i file con 1239 aggiunte e 61 eliminazioni
  1. 192 0
      algo-test.html
  2. 843 61
      index.html
  3. 93 0
      runtime-test.html
  4. 111 0
      test.html

+ 192 - 0
algo-test.html

@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html><head><meta charset="UTF-8"><title>Core Logic Test</title>
+<style>
+body{background:#111;color:#0f0;font-family:monospace;padding:20px;white-space:pre-wrap;font-size:13px}
+.err{color:#f44}.ok{color:#0f0}.warn{color:#fa0}.info{color:#88f}
+</style>
+</head>
+<body>
+<h3 style="color:#0ff">Eye Tracking - Core Algorithm Unit Test</h3>
+<div id="out"></div>
+<script>
+const O = document.getElementById('out');
+let pass=0,fail=0;
+function log(s,c){const d=document.createElement('div');d.className=c||'';d.textContent=s;O.appendChild(d)}
+function assert(cond,label){if(cond){pass++;log('  PASS: '+label,'ok')}else{fail++;log('  FAIL: '+label,'err')}}
+
+// ============ TEST 1: computeIrisGaze with right-eye flip ============
+log('=== TEST 1: computeIrisGaze right-eye flip ===','info');
+
+// Simulate: user looking RIGHT in un-mirrored image
+// Left eye: iris shifted toward outer (33, x=0.30), inner at x=0.35
+// Right eye: iris shifted toward outer (362, x=0.75), inner at x=0.65
+// In un-mirrored: looking right means iris goes toward L_OUTER (smaller x) and R_OUTER (larger x)
+function computeIrisGaze(landmarks) {
+  const L_OUTER=33,L_INNER=133,L_TOP=159,L_BOT=145,L_IRIS=468;
+  const R_OUTER=362,R_INNER=263,R_TOP=386,R_BOT=374,R_IRIS=473;
+  
+  function eyeData(outerIdx,innerIdx,topIdx,botIdx,irisIdx){
+    const outer=landmarks[outerIdx],inner=landmarks[innerIdx],top=landmarks[topIdx],bot=landmarks[botIdx],iris=landmarks[irisIdx];
+    if(!outer||!inner||!iris)return null;
+    if((iris.x===0&&iris.y===0)||Number.isNaN(iris.x)||Number.isNaN(iris.y))return null;
+    const eyeW=outer.x-inner.x;
+    if(Math.abs(eyeW)<1e-6)return null;
+    const ratioX=(iris.x-inner.x)/eyeW;
+    const midY=(top.y+bot.y)*0.5;
+    const ratioY=(iris.y-midY)/Math.abs(eyeW);
+    return{ratioX,ratioY};
+  }
+
+  const l_outer=landmarks[L_OUTER],l_inner=landmarks[L_INNER],l_top=landmarks[L_TOP],l_bot=landmarks[L_BOT],l_iris=landmarks[L_IRIS];
+  const left=(l_outer&&l_inner&&l_iris&&!(l_iris.x===0&&l_iris.y===0)&&!Number.isNaN(l_iris.x)&&!Number.isNaN(l_iris.y)&&Math.abs(l_outer.x-l_inner.x)>1e-6)?(()=>{
+    const eyeW=l_outer.x-l_inner.x;const ratioX=(l_iris.x-l_inner.x)/eyeW;const midY=(l_top.y+l_bot.y)*0.5;const ratioY=(l_iris.y-midY)/Math.abs(eyeW);return{ratioX,ratioY};
+  })():null;
+
+  const r_outer=landmarks[R_OUTER],r_inner=landmarks[R_INNER],r_top=landmarks[R_TOP],r_bot=landmarks[R_BOT],r_iris=landmarks[R_IRIS];
+  const right=(r_outer&&r_inner&&r_iris&&!(r_iris.x===0&&r_iris.y===0)&&!Number.isNaN(r_iris.x)&&!Number.isNaN(r_iris.y)&&Math.abs(r_inner.x-r_outer.x)>1e-6)?(()=>{
+    const r_eyeW=r_inner.x-r_outer.x;const r_ratioX=(r_iris.x-r_outer.x)/r_eyeW;const r_midY=(r_top.y+r_bot.y)*0.5;const r_ratioY=(r_iris.y-r_midY)/Math.abs(r_eyeW);return{ratioX:r_ratioX,ratioY:r_ratioY};
+  })():null;
+
+  if(!left&&!right)return{ratioX:0.5,ratioY:0.5,visible:false};
+  let rx,ry;
+  if(left&&right){rx=(left.ratioX+right.ratioX)*0.5;ry=(left.ratioY+right.ratioY)*0.5}
+  else{const s=left||right;rx=s.ratioX;ry=s.ratioY}
+  return{ratioX:rx,ratioY:ry,visible:true};
+}
+
+function makeLm(obj){const lm=new Array(478);for(let i=0;i<478;i++){lm[i]={x:0,y:0,z:0}};for(const[k,v]of Object.entries(obj)){lm[parseInt(k)]={x:v[0],y:v[1],z:0}};return lm}
+
+// Case 1: Looking CENTER
+const lmCenter = makeLm({
+  33:[0.30,0.50], 133:[0.35,0.50], 159:[0.31,0.47], 145:[0.31,0.53], 468:[0.325,0.50],
+  362:[0.75,0.50], 263:[0.70,0.50], 386:[0.69,0.47], 374:[0.69,0.53], 473:[0.725,0.50]
+});
+const gCenter = computeIrisGaze(lmCenter);
+log('Looking CENTER: ratioX='+gCenter.ratioX.toFixed(4)+' ratioY='+gCenter.ratioY.toFixed(4));
+assert(Math.abs(gCenter.ratioX-0.5)<0.05, 'Center X should be ~0.5 (got '+gCenter.ratioX.toFixed(4)+')');
+assert(gCenter.visible, 'Center should be visible');
+
+// Case 2: Looking RIGHT (iris shifts toward outer corners in un-mirrored image)
+const lmRight = makeLm({
+  33:[0.30,0.50], 133:[0.35,0.50], 159:[0.31,0.47], 145:[0.31,0.53], 468:[0.29,0.50],  // left iris closer to outer
+  362:[0.75,0.50], 263:[0.70,0.50], 386:[0.69,0.47], 374:[0.69,0.53], 473:[0.76,0.50]  // right iris closer to outer
+});
+const gRight = computeIrisGaze(lmRight);
+log('Looking RIGHT: ratioX='+gRight.ratioX.toFixed(4)+' ratioY='+gRight.ratioY.toFixed(4));
+assert(gRight.ratioX < 0.45, 'Looking RIGHT: X should be < 0.45 (got '+gRight.ratioX.toFixed(4)+')');
+
+// Case 3: Looking LEFT (iris shifts toward inner corners)
+const lmLeft = makeLm({
+  33:[0.30,0.50], 133:[0.35,0.50], 159:[0.31,0.47], 145:[0.31,0.53], 468:[0.34,0.50],
+  362:[0.75,0.50], 263:[0.70,0.50], 386:[0.69,0.47], 374:[0.69,0.53], 473:[0.69,0.50]
+});
+const gLeft = computeIrisGaze(lmLeft);
+log('Looking LEFT: ratioX='+gLeft.ratioX.toFixed(4)+' ratioY='+gLeft.ratioY.toFixed(4));
+assert(gLeft.ratioX > 0.55, 'Looking LEFT: X should be > 0.55 (got '+gLeft.ratioX.toFixed(4)+')');
+
+// Case 4: Looking UP
+const lmUp = makeLm({
+  33:[0.30,0.50], 133:[0.35,0.50], 159:[0.31,0.47], 145:[0.31,0.53], 468:[0.325,0.49],
+  362:[0.75,0.50], 263:[0.70,0.50], 386:[0.69,0.47], 374:[0.69,0.53], 473:[0.725,0.49]
+});
+const gUp = computeIrisGaze(lmUp);
+log('Looking UP: ratioX='+gUp.ratioX.toFixed(4)+' ratioY='+gUp.ratioY.toFixed(4));
+assert(gUp.ratioY < -0.01, 'Looking UP: Y should be negative (got '+gUp.ratioY.toFixed(4)+')');
+
+// Case 5: Looking DOWN
+const lmDown = makeLm({
+  33:[0.30,0.50], 133:[0.35,0.50], 159:[0.31,0.47], 145:[0.31,0.53], 468:[0.325,0.51],
+  362:[0.75,0.50], 263:[0.70,0.50], 386:[0.69,0.47], 374:[0.69,0.53], 473:[0.725,0.51]
+});
+const gDown = computeIrisGaze(lmDown);
+log('Looking DOWN: ratioX='+gDown.ratioX.toFixed(4)+' ratioY='+gDown.ratioY.toFixed(4));
+assert(gDown.ratioY > 0.01, 'Looking DOWN: Y should be positive (got '+gDown.ratioY.toFixed(4)+')');
+
+// ============ TEST 2: OLS Linear Regression ============
+log('\n=== TEST 2: Linear Regression (OLS) ===','info');
+
+function solve3x3(A,b){
+  const det=(A[0][0]*(A[1][1]*A[2][2]-A[1][2]*A[2][1])-A[0][1]*(A[1][0]*A[2][2]-A[1][2]*A[2][0])+A[0][2]*(A[1][0]*A[2][1]-A[1][1]*A[2][0]));
+  if(Math.abs(det)<1e-9)return null;
+  const d0=(b[0]*(A[1][1]*A[2][2]-A[1][2]*A[2][1])-A[0][1]*(b[1]*A[2][2]-A[1][2]*b[2])+A[0][2]*(b[1]*A[2][1]-A[1][1]*b[2]));
+  const d1=(A[0][0]*(b[1]*A[2][2]-A[1][2]*b[2])-b[0]*(A[1][0]*A[2][2]-A[1][2]*A[2][0])+A[0][2]*(A[1][0]*b[2]-b[1]*A[2][0]));
+  const d2=(A[0][0]*(A[1][1]*b[2]-b[1]*A[2][1])-A[0][1]*(A[1][0]*b[2]-b[1]*A[2][0])+b[0]*(A[1][0]*A[2][1]-A[1][1]*A[2][0]));
+  return[d0/det,d1/det,d2/det];
+}
+
+function olsFit(X,y){
+  const n=X.length;const A=[[0,0,0],[0,0,0],[0,0,0]];const b=[0,0,0];
+  for(let i=0;i<n;i++){const xi=X[i];for(let r=0;r<3;r++){for(let c=0;c<3;c++)A[r][c]+=xi[r]*xi[c];b[r]+=xi[r]*y[i]}}
+  return solve3x3(A,b);
+}
+
+function fitCalibration(pts){
+  const avgs=pts.map(p=>{let sx=0,sy=0;for(let i=0;i<p.samples.length;i++){sx+=p.samples[i].ratioX;sy+=p.samples[i].ratioY}return{ratioX:sx/p.samples.length,ratioY:sy/p.samples.length,screenX:p.screenX,screenY:p.screenY}});
+  const X=avgs.map(p=>[1,p.ratioX,p.ratioY]);
+  const cx=olsFit(X,avgs.map(p=>p.screenX));
+  const cy=olsFit(X,avgs.map(p=>p.screenY));
+  if(!cx||!cy)return null;
+  return{coefX:[cx[0],cx[1],cx[2]],coefY:[cy[0],cy[1],cy[2]]};
+}
+
+// Simulate 9-point calibration with ideal data
+// At each screen position, generate 20 iris ratio samples
+const calPts = [
+  {x:0.15,y:0.15},{x:0.5,y:0.15},{x:0.85,y:0.15},
+  {x:0.15,y:0.5},{x:0.5,y:0.5},{x:0.85,y:0.5},
+  {x:0.15,y:0.85},{x:0.5,y:0.85},{x:0.85,y:0.85}
+];
+
+const calData = calPts.map(screenPt => {
+  // Iris ratio roughly maps: ratioX=0.3→left, 0.7→right; ratioY=-0.03→up, 0.03→down
+  const rx = 0.3 + screenPt.x * 0.4; // screen 0→ratioX 0.3, screen 1→ratioX 0.7
+  const ry = -0.03 + screenPt.y * 0.06; // screen 0→ratioY -0.03, screen 1→ratioY 0.03
+  const samples = [];
+  for(let i=0;i<20;i++){
+    samples.push({ratioX: rx + (Math.random()-0.5)*0.01, ratioY: ry + (Math.random()-0.5)*0.002});
+  }
+  return {screenX: screenPt.x, screenY: screenPt.y, samples};
+});
+
+const fit = fitCalibration(calData);
+if(!fit){log('FAIL: OLS fit returned null','err')}else{
+  log('Calibration coefficients:', 'ok');
+  log('  coefX = ['+fit.coefX.map(v=>v.toFixed(6)).join(', ')+']');
+  log('  coefY = ['+fit.coefY.map(v=>v.toFixed(6)).join(', ')+']');
+  
+  // Test: predict center (ratioX=0.5, ratioY=0)
+  const predX = fit.coefX[0] + fit.coefX[1]*0.5 + fit.coefX[2]*0;
+  const predY = fit.coefY[0] + fit.coefY[1]*0.5 + fit.coefY[2]*0;
+  log('Predict center (0.5,0): screenX='+predX.toFixed(3)+' screenY='+predY.toFixed(3));
+  assert(Math.abs(predX-0.5)<0.05, 'Center prediction X should be ~0.5');
+  assert(Math.abs(predY-0.5)<0.05, 'Center prediction Y should be ~0.5');
+  
+  // Test: predict corners
+  const tlx = fit.coefX[0] + fit.coefX[1]*0.3 + fit.coefX[2]*(-0.03);
+  const tly = fit.coefY[0] + fit.coefY[1]*0.3 + fit.coefY[2]*(-0.03);
+  log('Predict TL (0.3,-0.03): screenX='+tlx.toFixed(3)+' screenY='+tly.toFixed(3));
+  assert(Math.abs(tlx-0.15)<0.1, 'TL prediction X should be near 0.15');
+  assert(Math.abs(tly-0.15)<0.1, 'TL prediction Y should be near 0.15');
+  
+  const brx = fit.coefX[0] + fit.coefX[1]*0.7 + fit.coefX[2]*0.03;
+  const bry = fit.coefY[0] + fit.coefY[1]*0.7 + fit.coefY[2]*0.03;
+  log('Predict BR (0.7,0.03): screenX='+brx.toFixed(3)+' screenY='+bry.toFixed(3);
+  assert(Math.abs(brx-0.85)<0.1, 'BR prediction X should be near 0.85');
+  assert(Math.abs(bry-0.85)<0.1, 'BR prediction Y should be near 0.85');
+}
+
+// ============ TEST 3: EMA + Outlier rejection ============
+log('\n=== TEST 3: EMA + Outlier ===','info');
+const EMA_ALPHA=0.3, OUTLIER_THRESHOLD=0.15;
+let emaX=0.5,emaY=0.5;
+function applyEMA(rx,ry){const dx=Math.abs(rx-emaX),dy=Math.abs(ry-emaY);if(dx>OUTLIER_THRESHOLD||dy>OUTLIER_THRESHOLD)return false;emaX=EMA_ALPHA*rx+(1-EMA_ALPHA)*emaX;emaY=EMA_ALPHA*ry+(1-EMA_ALPHA)*emaY;return true}
+
+assert(applyEMA(0.5,0.5)==true, 'EMA accepts small change');
+assert(Math.abs(emaX-0.5)<0.01, 'EMA stays near 0.5 for input 0.5');
+assert(applyEMA(0.8,0.8)==false, 'EMA rejects large jump (>0.15)');
+assert(Math.abs(emaX-0.5)<0.01, 'EMA holds after rejection');
+
+log('\n=== SUMMARY: '+pass+' passed, '+fail+' failed ===', fail>0?'err':'ok');
+</script>
+</body>
+</html>

File diff suppressed because it is too large
+ 843 - 61
index.html


+ 93 - 0
runtime-test.html

@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html><head><meta charset="UTF-8"><title>Algorithm Test</title></head>
+<body>
+<pre id="out"></pre>
+<script>
+const out = document.getElementById('out');
+function log(s) { out.textContent += s + '\n'; }
+
+// ============ Extract and test the core algorithm ============
+fetch('/eye-demo/index.html').then(r=>r.text()).then(html => {
+  const match = html.match(/<script>\(function \(\) \{([\s\S]+)\}\)\(\);<\/script>/);
+  if (!match) { log('FAIL: no script'); return; }
+  
+  try {
+    new Function(match[1]);
+    log('PASS: JS syntax valid');
+  } catch(e) {
+    log('FAIL: JS syntax error: ' + e.message);
+    return;
+  }
+
+  // Now run the actual page in an iframe to check runtime
+  log('\n--- Runtime test (iframe) ---');
+  
+  const iframe = document.createElement('iframe');
+  iframe.style.width = '0';
+  iframe.style.height = '0';
+  iframe.style.border = 'none';
+  document.body.appendChild(iframe);
+  
+  const iframeDoc = iframe.contentDocument;
+  iframeDoc.open();
+  iframeDoc.write(html);
+  iframeDoc.close();
+  
+  // Wait a moment for IIFE to execute
+  setTimeout(() => {
+    try {
+      const win = iframe.contentWindow;
+      
+      // Check that the IIFE didn't throw
+      log('PASS: IIFE executed without throwing');
+      
+      // Check localStorage
+      const calData = localStorage.getItem('eye-tracking-calibration');
+      if (calData) {
+        log('INFO: Found existing calibration data: ' + calData.substring(0, 100) + '...');
+      } else {
+        log('INFO: No calibration data in localStorage (expected on first run)');
+      }
+      
+      // Check if stage canvas exists
+      const stage = iframeDoc.getElementById('stage');
+      log('Stage canvas: ' + (stage ? 'OK (' + stage.width + 'x' + stage.height + ')' : 'MISSING'));
+      
+      // Check calibration overlay
+      const calOverlay = iframeDoc.getElementById('calibration-overlay');
+      log('Calibration overlay: ' + (calOverlay ? 'exists' : 'MISSING'));
+      if (calOverlay) {
+        log('  has show class: ' + calOverlay.classList.contains('show'));
+      }
+      
+      // Check status text
+      const statusText = iframeDoc.getElementById('status-text');
+      log('Status text: ' + (statusText ? '"' + statusText.textContent + '"' : 'MISSING'));
+      
+      // Check cal status
+      const calStatusText = iframeDoc.getElementById('cal-status-text');
+      log('Cal status: ' + (calStatusText ? '"' + calStatusText.textContent + '"' : 'MISSING'));
+      
+      // Check recalibrate button
+      const recalBtn = iframeDoc.getElementById('recalibrate-btn');
+      log('Recalibrate btn: ' + (recalBtn ? 'exists (disabled=' + recalBtn.disabled + ')' : 'MISSING'));
+      
+      // Check debug panel
+      const dbgStage = iframeDoc.getElementById('dbg-stage');
+      log('dbg-stage element: ' + (dbgStage ? 'exists' : 'MISSING (bug: JS looks for debug-stage but HTML id is dbg-stage)'));
+      
+      log('\n--- All runtime checks done ---');
+      
+    } catch(e) {
+      log('FAIL: Runtime error: ' + e.message);
+      log('Stack: ' + e.stack);
+    }
+    
+    // Clean up
+    document.body.removeChild(iframe);
+  }, 2000);
+  
+}).catch(e => log('Fetch error: ' + e.message));
+</script>
+</body>
+</html>

+ 111 - 0
test.html

@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<title>Eye Demo - Debug Test</title>
+<style>
+  body { background: #111; color: #0f0; font-family: monospace; padding: 20px; white-space: pre-wrap; font-size: 13px; }
+  .err { color: #f44; }
+  .ok { color: #0f0; }
+  .warn { color: #fa0; }
+</style>
+</head>
+<body>
+<h2>Eye Tracking Debug Test</h2>
+<div id="output"></div>
+<script>
+// Extract and test the JS from index.html
+fetch('/eye-demo/index.html')
+  .then(r => r.text())
+  .then(html => {
+    const out = document.getElementById('output');
+    function log(msg, cls) {
+      const div = document.createElement('div');
+      div.className = cls || '';
+      div.textContent = msg;
+      out.appendChild(div);
+    }
+
+    // 1. Extract main script
+    const match = html.match(/<script>\(function \(\) \{([\s\S]+)\}\)\(\);<\/script>/);
+    if (!match) {
+      log('ERROR: Could not extract main IIFE script', 'err');
+      return;
+    }
+    log('Script extracted OK (' + match[1].length + ' chars)', 'ok');
+
+    // 2. Syntax check
+    try {
+      new Function(match[1]);
+      log('JS SYNTAX: VALID', 'ok');
+    } catch(e) {
+      log('JS SYNTAX ERROR: ' + e.message, 'err');
+      // Try to find the error location
+      log('Error stack: ' + e.stack, 'err');
+    }
+
+    // 3. Check DOM element IDs referenced in JS
+    const script = match[1];
+    const ids = script.match(/getElementById\(['"]([^'"]+)['"]\)/g) || [];
+    log('\n--- DOM ID Check (' + ids.length + ' refs) ---');
+    let missingCount = 0;
+    ids.forEach(ref => {
+      const id = ref.match(/getElementById\(['"]([^'"]+)['"]\)/)[1];
+      const exists = html.indexOf('id="' + id + '"') !== -1;
+      if (!exists) {
+        log('  MISSING ID: "' + id + '" (JS looks for it but HTML has no such id)', 'err');
+        missingCount++;
+      }
+    });
+    if (missingCount === 0) log('  All DOM IDs found in HTML', 'ok');
+
+    // 4. Key logic flow check
+    log('\n--- Logic Flow ---');
+
+    // Check that calibration flow doesn't have issues
+    const hasCalStart = script.indexOf('startCalibration()') !== -1;
+    const hasCalFinish = script.indexOf('finishCalibration()') !== -1;
+    const hasOnResults = script.indexOf('function onResults') !== -1;
+    const hasApplyRegression = script.indexOf('applyRegression') !== -1;
+    const hasFrameSkip = script.indexOf('frameCount % 2') !== -1;
+
+    log('  startCalibration: ' + (hasCalStart ? 'found' : 'MISSING'), hasCalStart ? 'ok' : 'err');
+    log('  finishCalibration: ' + (hasCalFinish ? 'found' : 'MISSING'), hasCalFinish ? 'ok' : 'err');
+    log('  onResults: ' + (hasOnResults ? 'found' : 'MISSING'), hasOnResults ? 'ok' : 'err');
+    log('  applyRegression: ' + (hasApplyRegression ? 'found' : 'MISSING'), hasApplyRegression ? 'ok' : 'err');
+    log('  frameSkip: ' + (hasFrameSkip ? 'found' : 'MISSING'), hasFrameSkip ? 'ok' : 'err');
+
+    // 5. Check right eye fix
+    const hasRFlip = script.indexOf('r_inner.x - r_outer.x') !== -1;
+    log('\n  Right eye flip fix: ' + (hasRFlip ? 'PRESENT' : 'MISSING'), hasRFlip ? 'ok' : 'err');
+
+    // 6. Check that old Kalman is removed
+    const hasKalman = script.indexOf('SimpleKalman') !== -1;
+    log('  Kalman removed: ' + (!hasKalman ? 'YES' : 'STILL PRESENT'), !hasKalman ? 'ok' : 'warn');
+
+    // 7. Check that head pose is removed
+    const hasHeadPose = script.indexOf('nose') !== -1 && script.indexOf('headOffY') !== -1;
+    log('  Head pose removed: ' + (!hasHeadPose ? 'YES' : 'STILL PRESENT'), !hasHeadPose ? 'ok' : 'warn');
+
+    // 8. Check EMA
+    const hasEMA = script.indexOf('EMA_ALPHA') !== -1;
+    log('  EMA smoothing: ' + (hasEMA ? 'PRESENT' : 'MISSING'), hasEMA ? 'ok' : 'err');
+
+    // 9. Check localStorage
+    const hasStorage = script.indexOf('localStorage') !== -1;
+    log('  localStorage: ' + (hasStorage ? 'PRESENT' : 'MISSING'), hasStorage ? 'ok' : 'err');
+
+    // 10. Check if there's an unused eyeData function inside computeIrisGaze
+    const computeGazeSection = script.match(/function computeIrisGaze[\s\S]*?function eyeData[\s\S]*?\n  \}/);
+    if (computeGazeSection) {
+      log('\n  WARNING: Unused nested eyeData() inside computeIrisGaze (dead code, harmless)', 'warn');
+    }
+
+    log('\n--- DONE ---');
+  })
+  .catch(e => {
+    document.getElementById('output').textContent = 'Fetch error: ' + e.message;
+  });
+</script>
+</body>
+</html>

Some files were not shown because too many files changed in this diff