camera-5.0: Upload 3 frames

This commit is contained in:
Fam Zheng 2025-05-10 23:01:45 +01:00
parent cd8d3527c7
commit 4cbb643740

View File

@ -147,6 +147,8 @@ function handle_frame() {
setTimeout(handle_frame, 20); setTimeout(handle_frame, 20);
} }
image_data_urls = [];
function do_handle_frame() { function do_handle_frame() {
if (busy) return; if (busy) return;
const canvas = document.getElementById("original"); const canvas = document.getElementById("original");
@ -174,7 +176,13 @@ function do_handle_frame() {
} }
if (done_checking_auto_torch && is_valid_pattern && res.ok) { if (done_checking_auto_torch && is_valid_pattern && res.ok) {
var data_url = canvas.toDataURL("image/jpeg", 1.0); var data_url = canvas.toDataURL("image/jpeg", 1.0);
submit_image(res.qrcode, res.angle, data_url); image_data_urls.push(data_url);
if (image_data_urls.length >= 3) {
submit_image(image_data_urls, res.qrcode, res.angle);
image_data_urls = [];
} else {
pending_hint = make_hint_text(res);
}
} else { } else {
pending_hint = make_hint_text(res); pending_hint = make_hint_text(res);
} }
@ -235,7 +243,7 @@ function hide_spinner() {
add_class_by_query('.verifyspin', 'hidden'); add_class_by_query('.verifyspin', 'hidden');
} }
async function submit_image(qrcode, angle, image_data_url) { async function submit_image(qrcode, angle, image_data_urls) {
busy = true; busy = true;
var begin = Date.now(); var begin = Date.now();
show_spinner(); show_spinner();
@ -253,7 +261,7 @@ async function submit_image(qrcode, angle, image_data_url) {
qrcode, qrcode,
angle, angle,
phonemodel, phonemodel,
image_data_url, image_data_urls,
log: debug_logs.join("\n"), log: debug_logs.join("\n"),
}; };
var r = await fetch("https://themblem.com/api/v1/qr-verify/", { var r = await fetch("https://themblem.com/api/v1/qr-verify/", {