changes face detection fps

This commit is contained in:
2026-09-24 05:57:57 +02:00
parent b36a950f85
commit e266baaeb9
2 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -45,7 +45,8 @@ MAX_FRAME_BYTES = 1 * 1024 * 1024
MAX_IMAGE_PIXELS = 20_000_000 MAX_IMAGE_PIXELS = 20_000_000
MAX_WEBSOCKETS = 3 MAX_WEBSOCKETS = 3
MAX_WEBSOCKETS_PER_IP = 1 MAX_WEBSOCKETS_PER_IP = 1
FACE_MIN_INTERVAL = 1 / 2.1 FACE_MAX_FPS = float(os.getenv("FACE_MAX_FPS", "5.5")) # per websocket connection
FACE_MIN_INTERVAL = 1 / FACE_MAX_FPS
DECODE_DRAFT_SIZE = (256, 256) # JPEG decodes at reduced scale, still larger than the 64px model input DECODE_DRAFT_SIZE = (256, 256) # JPEG decodes at reduced scale, still larger than the 64px model input
torch.set_num_threads(TORCH_THREADS) torch.set_num_threads(TORCH_THREADS)
+6 -1
View File
@@ -3,6 +3,11 @@ import { useRef, useEffect, useState } from 'react'
const FRAME_QUALITY = 0.7; const FRAME_QUALITY = 0.7;
// How many frames per second are sent to the API. The server drops frames
// arriving faster than ~2.1/s (FACE_MAX_FPS in server.py), so values
// above that have no effect unless the server limit is raised too.
const FRAMES_PER_SECOND = 5;
function Object_Detection() { function Object_Detection() {
const videoRef = useRef(null); const videoRef = useRef(null);
const canvasRefBBox = useRef(null); const canvasRefBBox = useRef(null);
@@ -125,7 +130,7 @@ function Object_Detection() {
if (!canvas) return; if (!canvas) return;
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
sendImageIntervall.current = setInterval(sendImage, 1000 / 2); sendImageIntervall.current = setInterval(sendImage, 1000 / FRAMES_PER_SECOND);
} }
socket.onmessage = (event) => { socket.onmessage = (event) => {
drawBBox(JSON.parse(event.data).bboxes); drawBBox(JSON.parse(event.data).bboxes);