fix(h5): relax capture angles and annotate acne marks

This commit is contained in:
xsl
2026-10-15 19:55:21 +08:00
parent 757b96dfad
commit 482fb4280d
9 changed files with 53 additions and 36 deletions
+15 -9
View File
@@ -28,27 +28,33 @@ const options = { count: 1, target: 'front', width: 600, height: 600, offsetX: 0
const check = (d, changes) => Quality.evaluate(d, { ...options, ...changes });
assert(check(face()).ok);
assert(!check(null).ok); assert(!check(face(), { count: 2 }).ok);
for (const yaw of [-14, 14]) assert(check(face(yaw)).ok, 'former strict front limit now passes');
for (const yaw of [-16, 16, -45, 45]) {
for (const yaw of [-17.99, 17.99]) assert(check(face(yaw)).ok, '20% relaxed front limit now passes');
for (const yaw of [-18.01, 18.01, -45, 45]) {
assert(!check(face(yaw)).ok);
assert.equal(check(face(yaw)).reason, 'angle');
assert.equal(check(face(yaw)).hint, '请正对屏幕', 'front correction must not ask for a side view before capture');
assert.equal(check(face(yaw), { mirrored: true }).hint, '请正对屏幕');
}
for (const pitch of [-17, 17]) assert(check(face(0, pitch)).ok);
for (const pitch of [-20, 20]) assert.equal(check(face(0, pitch)).hint, '请正对屏幕');
for (const pitch of [-21.59, 21.59]) assert(check(face(0, pitch)).ok);
for (const pitch of [-21.61, 21.61]) assert.equal(check(face(0, pitch)).hint, '请正对屏幕');
assert.equal(check(face(0), { target: 'right' }).hint, '请向左转头', 'side step retains its proper turn instruction');
assert.equal(check(face(0), { target: 'left' }).hint, '请向右转头');
assert(check(face(0, 0, 12)).ok, 'normal tilt now passes');
assert.equal(check(face(0, 0, 16)).hint, '请勿歪头');
for (const yaw of [25, 72]) assert(!check(face(yaw), { target: 'right' }).ok);
for (const yaw of [32, 68]) assert(check(face(yaw), { target: 'right' }).ok);
assert(check(face(0,0,17.99)).ok);
assert.equal(check(face(0, 0, 18.01)).hint, '请勿歪头');
for (const target of ['left','right']) {
const sign=target==='left'?-1:1;
for (const yaw of [23.99,84.01]) assert(!check(face(sign*yaw),{target}).ok);
for (const yaw of [24.01,83.99]) assert(check(face(sign*yaw),{target}).ok);
for (const pitch of [-23.99,23.99]) assert(check(face(sign*45,pitch),{target}).ok);
for (const pitch of [-24.01,24.01]) assert(!check(face(sign*45,pitch),{target}).ok);
}
assert(check(face(45), { target: 'right' }).ok);
assert(!check(face(45), { target: 'left' }).ok);
assert(check(face(-45), { target: 'left' }).ok);
assert(check(face(-45), { target: 'right', mirrored: true }).ok);
assert(check(face(-45), { target: 'right', ignoreDirection: true }).ok);
assert(!check(face(25), { target: 'left', ignoreDirection: true }).ok);
assert(!check(face(23), { target: 'left', ignoreDirection: true }).ok);
for (const luma of [null, 50, 240, NaN]) assert(!check(face(), { luma }).ok);
assert.equal(check(face(), { luma: 50 }).reason, 'quality', 'lighting must not trigger angle vibration');
assert.equal(check(null).reason, 'quality');
@@ -108,7 +114,7 @@ assert.equal(Diagnostics.assess(raw).views.right.status, 'valid');
const normalized = Diagnostics.normalize({ version: Quality.config.version, secret: 'discard', views: { front: { mode: 'live', yaw: 1, score: .9, luma: Infinity, secret: 'discard' }, left: { mode: 'unchecked', reason: 'model-unavailable' } } });
assert.equal(normalized.policy.capture.holdMs, 450);
assert.equal(normalized.policy.capture.minFrames, 2);
assert.equal(normalized.version, '2026-10-12-fourth-v2');
assert.equal(normalized.version, '2026-10-15-angle-relaxed-20-v3');
assert.equal(normalized.views.front.luma, undefined);
assert(!JSON.stringify(normalized).includes('discard'));
assert.equal(Diagnostics.normalize({ version: '<script>' }).version, 'unknown');