feat(h5): apply fourth feedback and tighten local capture validation
This commit is contained in:
@@ -33,7 +33,7 @@ assert(context.captureHaptic({ vibrate: p => { pattern = Array.from(p); return t
|
||||
assert.deepEqual(pattern, [70, 40, 70]);
|
||||
|
||||
// Exercise the actual readiness state machine; only camera/pose inputs and clock
|
||||
// are stubs. No detector thresholds, hold time or capture sequence are changed.
|
||||
// are stubs; the fourth-round shared hold policy now requires 650ms/3 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,
|
||||
@@ -41,19 +41,24 @@ const state = {
|
||||
HeadPose: { check: () => ({ ok: true }) }, sideYawFlip: false, faceLuma: () => 100,
|
||||
LUMA_DARK: 65, LUMA_BRIGHT: 235, window: {}, setMask: () => {}, setHint: () => {},
|
||||
okSince: 0, readyHapticAt: 0, OK_HOLD_MS: 450, Date: { now: () => now },
|
||||
holdState: null, CaptureQuality: {
|
||||
evaluate: d => ({ ok: d.detection.box.height >= 100, hint: '保持不动', observation: { yaw: 0, pitch: 0, center_x: .5, center_y: .5, ratio: .5 } }),
|
||||
hold: require('../js/capture-quality').hold
|
||||
},
|
||||
navigator: { vibrate: () => { buzzes++; return true; } }, doCapture: () => { captures++; }
|
||||
};
|
||||
vm.runInNewContext(extract('camera-haptic-pure') + source.slice(source.indexOf(' function onDetect(d)'), source.indexOf(' /* ─── 拍照流程')), state);
|
||||
const face = { detection: { box: { height: 250 } }, landmarks: { positions: [] } };
|
||||
state.onDetect(face); assert.equal(buzzes, 1); assert.equal(captures, 0);
|
||||
now += 200; state.onDetect(face); assert.equal(buzzes, 1); assert.equal(captures, 0);
|
||||
now += 250; state.onDetect(face); assert.equal(buzzes, 1); assert.equal(captures, 1);
|
||||
now += 450; state.onDetect(face); assert.equal(buzzes, 1); assert.equal(captures, 1);
|
||||
now += 100; state.onDetect({ ...face, detection: { box: { height: 20 } } });
|
||||
now += 100; state.onDetect(face); assert.equal(buzzes, 1, 'jitter must not repeatedly buzz');
|
||||
now += 2100; state.onDetect({ ...face, detection: { box: { height: 20 } } });
|
||||
state.onDetect(face); assert.equal(buzzes, 2);
|
||||
state.navigator.vibrate = () => { throw Error('blocked'); };
|
||||
now += 450; state.onDetect(face); assert.equal(captures, 2, 'vibration failure must not prevent capture');
|
||||
now += 300; state.onDetect(face);
|
||||
now += 350; state.onDetect(face); assert.equal(captures, 2, 'vibration failure must not prevent capture');
|
||||
for (const manual of [true, false]) {
|
||||
let manualBuzzes = 0, scheduled = [];
|
||||
const shutter = { shutterLock: false, camLive: true, capturing: false, camSeq: 1,
|
||||
@@ -66,4 +71,4 @@ for (const manual of [true, false]) {
|
||||
assert(shutter.shutterLock && shutter.capturing);
|
||||
assert.deepEqual(scheduled, [300], 'blocked haptic must still schedule camera capture');
|
||||
}
|
||||
console.log('PASS: three bounded rounded contours, invalid outline fallback, no geometry mutation; haptic missing/false/exception safety, pre-capture cue, jitter throttling, unchanged 450ms auto-capture');
|
||||
console.log('PASS: three bounded rounded contours; haptic safety, pre-capture cue, jitter throttling; fourth-round 650ms/3-frame hold');
|
||||
|
||||
Reference in New Issue
Block a user