fix(camera): constrain brightness and adjust side photo previews
This commit is contained in:
@@ -51,14 +51,16 @@ try {
|
||||
AudioRecorder.prototype = OriginalAudioContext.prototype;
|
||||
window.AudioContext = window.webkitAudioContext = AudioRecorder;
|
||||
const canvas = document.createElement('canvas'); canvas.width = 800; canvas.height = 600;
|
||||
let currentImage, offsetX = 0;
|
||||
let currentImage, offsetX = 0, lightGain = 1;
|
||||
function draw() {
|
||||
if (!currentImage) return;
|
||||
const c = canvas.getContext('2d'); c.fillStyle = '#111'; c.fillRect(0, 0, canvas.width, canvas.height);
|
||||
c.filter='brightness('+lightGain+')';
|
||||
c.drawImage(currentImage, offsetX, 0, canvas.width, canvas.height);
|
||||
c.filter='none';
|
||||
}
|
||||
setInterval(draw, 100);
|
||||
window.__cameraFixture = { canvas, set: async name => {
|
||||
window.__cameraFixture = { canvas, light:gain=>{lightGain=gain;draw();}, set: async name => {
|
||||
const image = new Image(); image.src = 'sample-' + name; await image.decode();
|
||||
// Simulate a person following the centering prompt, not an off-center
|
||||
// landscape source stretched into a portrait camera frame.
|
||||
@@ -115,6 +117,10 @@ try {
|
||||
assert((await page.locator('#cam-step').textContent()).includes('1/3'), 'invalid frontal angle never advances');
|
||||
assert.equal(await page.evaluate(() => window.__voice.some(row => /^hint-turn-|^step[23]-|^shot-done$/.test(row.id))), false, 'no turn/next-step/completion audio before a successful front photo');
|
||||
await page.evaluate(() => window.__cameraFixture.set('C3_180.jpg'));
|
||||
await page.waitForFunction(()=>window.__evaluations.some(row=>row.target==='front'&&!row.ok&&row.hint==='请到光线充足处'));
|
||||
assert((await page.locator('#cam-step').textContent()).includes('1/3'),'dim sample cannot advance');
|
||||
// Simulate improving room lighting, not bypassing the actual quality gate.
|
||||
await page.evaluate(()=>window.__cameraFixture.light(1.3));
|
||||
try { await page.waitForFunction(() => document.querySelector('#cam-step').textContent.includes('2/3')); }
|
||||
catch (error) {
|
||||
console.log(await page.evaluate(async () => {
|
||||
@@ -146,7 +152,7 @@ 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 >= .4 && row.luma >= 100 && row.luma <= 235);
|
||||
assert(row.score >= .4 && row.luma >= 150 && row.luma <= 220);
|
||||
assert(Math.abs(row.roll) <= 18);
|
||||
}
|
||||
assert(Math.abs(body.capture_diagnostics.views.front.yaw) <= 18);
|
||||
|
||||
Reference in New Issue
Block a user