fix(camera): make lighting checks advisory only

This commit is contained in:
xsl
2026-10-16 15:51:07 +08:00
parent 9ff7a582af
commit 6a628f837b
5 changed files with 28 additions and 17 deletions
+1 -1
View File
@@ -1036,7 +1036,7 @@
updateAngleHaptic(!!(verdict && verdict.reason === 'angle'), Date.now());
setMask(ok ? 'ok' : (noFace ? 'no-face' : ''));
// 合格时「保持不动」只显示不播报:随即抓拍,「拍摄完成」会截断它
setHint(ok ? '保持不动' : hint, ok, ok);
setHint(ok ? (verdict.warning ? verdict.warning + ',保持不动即可拍摄' : '保持不动') : hint, ok, ok);
if (!ok) { okSince = 0; holdState = null; return; }
var held = CaptureQuality.hold(holdState, verdict.observation, Date.now());
holdState = held.state;
+6 -6
View File
@@ -6,7 +6,7 @@
'use strict';
// Real-phone feedback: ease alignment and normal hand/head movement while
// retaining two checked frames, one face, framing and final JPEG validation.
var config = Object.freeze({ version: '2026-10-16-confidence-v9', score: 0.3, frontScore: 0.25,
var config = Object.freeze({ version: '2026-10-16-light-advisory-v10', score: 0.3, frontScore: 0.25,
near: 0.30, far: 0.68, center: 0.16, edge: 0.01,
dark: 110, bright: 220, holdMs: 450, minFrames: 2, maxGapMs: 2000,
yawDrift: 8, pitchDrift: 8, centerDrift: 0.055, sizeDrift: 0.065 });
@@ -33,11 +33,11 @@
if (options.ignoreDirection && target !== 'front') target = pose.yaw < 0 ? 'left' : 'right';
var check = HeadPose.check(d.landmarks.positions, target, options.mirrored);
if (!check.ok) return failed(check.hint, finite(check.yaw) ? 'angle' : 'quality');
if (!finite(options.luma)) return failed('请保持面部清晰');
if (options.luma < config.dark) return failed('请到光线充足处');
if (options.luma > config.bright) return failed('光线过强,请避开强光');
return { ok: true, hint: '保持不动', observation: { yaw: pose.yaw, pitch: pose.pitch, roll: pose.roll,
score: d.detection.score, luma: options.luma, ratio: ratio,
// Lighting is advisory for both live frames and saved JPEGs, never a gate.
var warning = finite(options.luma) && options.luma < config.dark ? '建议到光线明亮处拍摄' :
finite(options.luma) && options.luma > config.bright ? '光线过强,建议避开强光' : '';
return { ok: true, hint: '保持不动', warning: warning, observation: { yaw: pose.yaw, pitch: pose.pitch, roll: pose.roll,
score: d.detection.score, luma: finite(options.luma) ? options.luma : null, ratio: ratio,
center_x: (box.x + box.width / 2) / w, center_y: (box.y + box.height / 2) / h } };
}
function hold(state, observation, now) {