fix(camera): relax initial frontal face recognition

This commit is contained in:
xsl
2026-10-16 15:27:36 +08:00
parent 8365ef459f
commit 30c90f8df5
5 changed files with 35 additions and 12 deletions
+15 -2
View File
@@ -43,7 +43,7 @@ assert.equal(pattern, 30);
// are stubs; the relaxed shared hold policy now requires 450ms/2 frames.
let now = 10000, buzzes = 0, captures = 0;
const state = {
missFrames: 0, MISS_FRAMES_MAX: 3, camVideo: { videoHeight: 600 }, FACE_NEAR: .30, FACE_FAR: .68,
missFrames: 0, MISS_FRAMES_MAX: 3, FRONT_MISS_FRAMES_MAX: 6, frontFaceSeen:false, camVideo: { videoHeight: 600 }, FACE_NEAR: .30, FACE_FAR: .68,
faceOffsetX: () => 0, CENTER_TOL: .18, CAM_STEPS: [{ target: 'front' }], camStep: 0,
HeadPose: { check: () => ({ ok: true }) }, sideYawFlip: false, faceLuma: () => 100,
LUMA_DARK: 65, LUMA_BRIGHT: 235, window: {}, setMask: () => {}, setHint: () => {},
@@ -113,4 +113,17 @@ for (const nav of [{}, { vibrate: () => false }, { vibrate: () => { throw Error(
state.navigator = nav; state.resetAngleHaptic();
state.onDetect(face); now += 1000; assert.doesNotThrow(() => state.onDetect(face));
}
console.log('PASS: rounded contours; 1s invalid-angle cue, 4s throttle, cancellation/lifecycle, unsupported safety; unchanged 450ms/2-frame capture hold');
const missingHints=[];state.setHint=text=>missingHints.push(text);
state.resetAngleHaptic();state.frontFaceSeen=false;state.missFrames=0;state.CAM_STEPS[0].target='front';
const priorCaptures=captures;
for(let i=0;i<5;i++)state.onDetect(null);
assert.equal(missingHints.length,0,'initial front misses are quiet for five detections');
state.onDetect(null);assert.equal(missingHints.at(-1),'未检测到人脸');
missingHints.length=0;state.missFrames=0;state.frontFaceSeen=true;
state.onDetect(null);state.onDetect(null);assert.equal(missingHints.length,0);
state.onDetect(null);assert.equal(missingHints.at(-1),'未检测到人脸','after seeing a front face retain normal missing detection');
missingHints.length=0;state.missFrames=0;state.frontFaceSeen=false;state.CAM_STEPS[0].target='right';
state.onDetect(null);state.onDetect(null);assert.equal(missingHints.length,0);
state.onDetect(null);assert.equal(missingHints.at(-1),'未检测到人脸','side missing threshold unchanged');
assert.equal(captures,priorCaptures,'warmup never permits capture without a face');
console.log('PASS: initial-front missing tolerance6 vs normal3, no empty capture; angle haptics/lifecycle and unchanged 450ms/2-frame hold');