fix(camera): relax initial frontal face recognition
This commit is contained in:
@@ -6,11 +6,12 @@
|
||||
'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-15-pitch-roll-relaxed-v7', score: 0.4,
|
||||
var config = Object.freeze({ version: '2026-10-16-front-detection-v8', score: 0.4, frontScore: 0.3,
|
||||
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 });
|
||||
function finite(v) { return typeof v === 'number' && isFinite(v); }
|
||||
function scoreThreshold(target) { return target === 'front' ? config.frontScore : config.score; }
|
||||
function evaluate(d, options) {
|
||||
var failed = function(hint, reason) { return { ok: false, hint: hint, reason: reason || 'quality' }; };
|
||||
if (!d) return failed('未检测到人脸');
|
||||
@@ -18,7 +19,7 @@
|
||||
var box = d.detection.box, w = options.width, h = options.height;
|
||||
if (!box || ![box.x, box.y, box.width, box.height, w, h].every(finite) || w <= 0 || h <= 0 || box.width <= 0 || box.height <= 0) return failed('请将脸部完整移入取景框');
|
||||
var ratio = box.height / h;
|
||||
if (!finite(d.detection.score) || d.detection.score < config.score) return failed('请保持面部清晰');
|
||||
if (!finite(d.detection.score) || d.detection.score < scoreThreshold(options.target)) return failed('请保持面部清晰');
|
||||
if (ratio < config.near) return failed('请靠近一点');
|
||||
if (ratio > config.far) return failed('请远一点');
|
||||
if (box.x < w * config.edge || box.y < h * config.edge || box.x + box.width > w * (1 - config.edge) || box.y + box.height > h * (1 - config.edge)) return failed('请将脸部完整移入取景框');
|
||||
@@ -51,5 +52,5 @@
|
||||
{ since: state.since, lastAt: now, frames: state.frames + 1, anchor: state.anchor };
|
||||
return { state: next, ready: now - next.since >= config.holdMs && next.frames >= config.minFrames };
|
||||
}
|
||||
return { config: config, evaluate: evaluate, hold: hold };
|
||||
return { config: config, scoreThreshold: scoreThreshold, evaluate: evaluate, hold: hold };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user