Spaces:
Sleeping
Sleeping
Update static/app.js
Browse files- static/app.js +12 -4
static/app.js
CHANGED
|
@@ -58,8 +58,15 @@ function drawFaceBoxes(faces) {
|
|
| 58 |
}
|
| 59 |
|
| 60 |
function updateDebugCrops(faces) {
|
| 61 |
-
|
| 62 |
-
debugCrops.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
cropCount.textContent = `${faces.length} faces`;
|
| 64 |
|
| 65 |
faces.forEach(face => {
|
|
@@ -69,7 +76,7 @@ function updateDebugCrops(faces) {
|
|
| 69 |
|
| 70 |
const img = document.createElement('img');
|
| 71 |
img.src = face.crop;
|
| 72 |
-
img.className = `w-16 h-16 rounded border-2 ${face.status === 'match' ? 'border-emerald-500' : 'border-slate-700'} object-cover`;
|
| 73 |
|
| 74 |
const badge = document.createElement('div');
|
| 75 |
badge.className = 'absolute bottom-0 left-0 right-0 bg-black/70 text-[8px] text-center py-0.5 truncate';
|
|
@@ -201,7 +208,8 @@ function processFrame() {
|
|
| 201 |
if (ws && ws.readyState === WebSocket.OPEN && !isProcessing) {
|
| 202 |
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
| 203 |
isProcessing = true;
|
| 204 |
-
|
|
|
|
| 205 |
}
|
| 206 |
requestAnimationFrame(processFrame);
|
| 207 |
}
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
function updateDebugCrops(faces) {
|
| 61 |
+
// Always clear previous crops
|
| 62 |
+
debugCrops.innerHTML = '';
|
| 63 |
+
|
| 64 |
+
if (!faces || faces.length === 0) {
|
| 65 |
+
debugCrops.innerHTML = '<div class="text-xs text-slate-600 italic">Waiting for detection...</div>';
|
| 66 |
+
cropCount.textContent = '0 faces';
|
| 67 |
+
return;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
cropCount.textContent = `${faces.length} faces`;
|
| 71 |
|
| 72 |
faces.forEach(face => {
|
|
|
|
| 76 |
|
| 77 |
const img = document.createElement('img');
|
| 78 |
img.src = face.crop;
|
| 79 |
+
img.className = `w-16 h-16 rounded border-2 ${face.status === 'match' ? 'border-emerald-500' : (face.status === 'fail' ? 'border-amber-500' : 'border-slate-700')} object-cover`;
|
| 80 |
|
| 81 |
const badge = document.createElement('div');
|
| 82 |
badge.className = 'absolute bottom-0 left-0 right-0 bg-black/70 text-[8px] text-center py-0.5 truncate';
|
|
|
|
| 208 |
if (ws && ws.readyState === WebSocket.OPEN && !isProcessing) {
|
| 209 |
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
| 210 |
isProcessing = true;
|
| 211 |
+
// Lowered to 0.8 quality for network stability
|
| 212 |
+
ws.send(JSON.stringify({ type: 'frame', image: canvas.toDataURL('image/jpeg', 0.8) }));
|
| 213 |
}
|
| 214 |
requestAnimationFrame(processFrame);
|
| 215 |
}
|