fix(h5): ease camera capture requirements and rename page title

This commit is contained in:
xsl
2026-10-12 20:47:58 +08:00
parent 3f165bf9e5
commit c9352fe4ca
15 changed files with 960 additions and 804 deletions
+6 -5
View File
@@ -48,6 +48,7 @@ try {
await route.fulfill({ json: fixture });
});
await page.goto(base); await page.click('[data-action="open-privacy"]');
assert.equal(await page.title(), "1'me肌肤状态检测");
await page.click('#privacy-check'); await page.click('[data-action="agree-continue"]');
for (const selector of ['#pick-birth', '#pick-gender', '#pick-region']) {
await page.click(selector); await page.click('.ms-mobile-select.ms-show .ms-ensure'); await page.waitForTimeout(400);
@@ -100,12 +101,12 @@ try {
for (const key of ['front', 'left', 'right']) {
const row = body.capture_diagnostics.views[key];
assert.equal(row.mode, 'live'); assert.equal(row.direction_checked, true);
assert(row.score >= .5 && row.luma >= 75 && row.luma <= 225);
assert(Math.abs(row.roll) <= 10);
assert(row.score >= .4 && row.luma >= 65 && row.luma <= 235);
assert(Math.abs(row.roll) <= 15);
}
assert(Math.abs(body.capture_diagnostics.views.front.yaw) <= 10);
assert(body.capture_diagnostics.views.left.yaw <= -35);
assert(body.capture_diagnostics.views.right.yaw >= 35);
assert(Math.abs(body.capture_diagnostics.views.front.yaw) <= 15);
assert(body.capture_diagnostics.views.left.yaw <= -30);
assert(body.capture_diagnostics.views.right.yaw >= 30);
assert(await page.evaluate(() => document.querySelector('#cam-video').srcObject === null), 'camera released after success');
assert.deepEqual(errors, []);
console.log('PASS: actual local models + automatic three-view capture + final JPEG revalidation; front/wrong-direction frames blocked locally; all three approved samples recorded; camera released; no paid call or backend writes');
+26 -13
View File
@@ -28,10 +28,14 @@ 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);
for (const pitch of [-18, 18]) assert(!check(face(0, pitch)).ok);
assert.equal(check(face(0, 0, 15)).hint, '请勿歪头');
for (const yaw of [-14, 14]) assert(check(face(yaw)).ok, 'former strict front limit now passes');
for (const yaw of [-16, 16]) assert(!check(face(yaw)).ok);
for (const pitch of [-17, 17]) assert(check(face(0, pitch)).ok);
for (const pitch of [-20, 20]) assert(!check(face(0, pitch)).ok);
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(45), { target: 'right' }).ok);
assert(!check(face(45), { target: 'left' }).ok);
assert(check(face(-45), { target: 'left' }).ok);
@@ -39,22 +43,29 @@ 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);
for (const luma of [null, 50, 240, NaN]) assert(!check(face(), { luma }).ok);
assert(!check(face(), { offsetX: .15 }).ok);
for (const changes of [{ height: 180 }, { height: 410 }, { x: -10 }, { y: 5 }]) {
for (const luma of [70, 230]) assert(check(face(), { luma }).ok);
assert(check(face(), { offsetX: .15 }).ok);
assert(!check(face(), { offsetX: .17 }).ok);
for (const changes of [{ height: 190 }, { height: 400 }, { y: 8 }]) {
const d = face(); Object.assign(d.detection.box, changes); assert(check(d).ok, 'former framing limits now pass');
}
for (const changes of [{ height: 179 }, { height: 410 }, { x: -10 }, { y: 5 }]) {
const d = face(); Object.assign(d.detection.box, changes); assert(!check(d).ok);
}
const weak = face(); weak.detection.score = .4; assert(!check(weak).ok);
const weak = face(); weak.detection.score = .45; assert(check(weak).ok);
weak.detection.score = .35; assert(!check(weak).ok);
const obs = check(face()).observation;
let held = Quality.hold(null, obs, 1000); assert(!held.ready);
held = Quality.hold(held.state, obs, 1400); assert(!held.ready);
assert(Quality.hold(held.state, obs, 1650).ready);
assert(!Quality.hold(Quality.hold(null, obs, 1000).state, obs, 1700).ready, 'two frames never pass');
assert(!Quality.hold(held.state, obs, 1449).ready);
assert(Quality.hold(held.state, obs, 1450).ready);
assert(Quality.hold(Quality.hold(null, obs, 1000).state, obs, 1450).ready, 'two stable frames at 450ms now pass');
assert.equal(Quality.hold(held.state, null, 1700).state, null);
assert.equal(Quality.hold(held.state, obs, 3500).state.frames, 1, 'gap resets');
const slow = Quality.hold(Quality.hold(null, obs, 1000).state, obs, 2100);
assert(!slow.ready, 'slow device still needs three frames');
assert(Quality.hold(slow.state, obs, 3200).ready, '1100ms inference must not permanently prevent a stable capture');
for (const change of [{ yaw: 6 }, { pitch: 6 }, { ratio: .6 }, { center_x: .55 }, { center_y: .56 }]) assert.equal(Quality.hold(held.state, { ...obs, ...change }, 1500).state.frames, 1, 'motion resets');
assert(slow.ready, '1100ms inference now only needs two checked frames');
for (const change of [{ yaw: 7 }, { pitch: 7 }, { ratio: .56 }, { center_x: .55 }, { center_y: .55 }]) assert(Quality.hold(held.state, { ...obs, ...change }, 1500).ready, 'small movement no longer resets');
for (const change of [{ yaw: 9 }, { pitch: 9 }, { ratio: .6 }, { center_x: .56 }, { center_y: .58 }]) assert.equal(Quality.hold(held.state, { ...obs, ...change }, 1500).state.frames, 1, 'large motion still resets');
for (const [dims, key] of [
[[10, 50, 90], 'firm'], [[90, 10, 50], 'vita'], [[90, 50, 10], 'stab'],
[[50, 50, 90], 'firm'], [[null, 50, 50], 'vita'], [[50.1, 50, 90], 'vita']
@@ -74,8 +85,10 @@ assert.equal(Diagnostics.assess(raw).status, 'invalid');
assert.equal(Diagnostics.assess({}).status, 'unavailable');
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, 650);
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.views.front.luma, undefined);
assert(!JSON.stringify(normalized).includes('discard'));
assert.equal(Diagnostics.normalize({ version: '<script>' }).version, 'unknown');
console.log('PASS: stricter local pose/framing/light/single-face gates; 650ms/3-frame stability/motion/miss/gap reset; all focus cases/ties/missing/saved scores; no wrinkle mutations; backend quality marking and bounded client diagnostics');
console.log('PASS: former strict pose/framing/light/motion limits now pass; invalid views/multiple faces/cropping/large movement still rejected; 450ms/2-frame stability/miss/gap reset; focus/history/backend diagnostics');
+4 -1
View File
@@ -43,6 +43,8 @@ try {
});
await page.route('**/vendor/faceapi/face-api.js', route => route.abort());
await page.goto(base); await page.waitForLoadState('networkidle');
assert.equal(await page.title(), "1'me肌肤状态检测");
assert.equal(await page.locator('meta[property="og:title"]').getAttribute('content'), "1'me肌肤状态检测");
assert.equal((await page.locator('[data-action="login-browser"]').textContent()).trim(), '游客登录');
assert(!requests.some(p => /scan-(base|face)|\.woff2$|faceapi/.test(p)), 'no heavy/scanning entry requests');
await page.check('#login-consent'); await page.click('[data-action="login-browser"]');
@@ -64,7 +66,8 @@ try {
assert.equal(admin.capture_quality.status, 'invalid');
assert.equal(admin.capture_quality.views.right.quality, 3);
assert.equal(admin.capture_diagnostics.version, CaptureQuality.config.version);
assert.equal(admin.capture_diagnostics.policy.pose.SIDE_YAW_MIN, 35);
assert.equal(admin.capture_diagnostics.policy.pose.SIDE_YAW_MIN, 30);
assert.equal(admin.capture_diagnostics.policy.capture.minFrames, 2);
assert.equal(admin.capture_diagnostics.ignore, undefined);
assert(admin.notes.some(n => n.includes('quality=3')));
const wrinkle = admin.presentation.views.find(view => view.key === 'wrinkles');
+4 -4
View File
@@ -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; the fourth-round shared hold policy now requires 650ms/3 frames.
// 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,
@@ -51,14 +51,14 @@ vm.runInNewContext(extract('camera-haptic-pure') + source.slice(source.indexOf('
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 += 450; state.onDetect(face); assert.equal(buzzes, 1); assert.equal(captures, 1);
now += 250; 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 += 300; state.onDetect(face);
now += 350; state.onDetect(face); assert.equal(captures, 2, 'vibration failure must not prevent capture');
now += 150; 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,
@@ -71,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; haptic safety, pre-capture cue, jitter throttling; fourth-round 650ms/3-frame hold');
console.log('PASS: three bounded rounded contours; haptic safety, pre-capture cue, jitter throttling; relaxed 450ms/2-frame hold');