Server 0.4

Server
ahmedmujtaba-gif 2026-04-16 19:22:27 +05:00
parent a8276a1b25
commit 4468400a0e
1 changed files with 6 additions and 0 deletions

View File

@ -208,6 +208,11 @@ def _process_stream(camera):
"fps": round(fps, 1) "fps": round(fps, 1)
}) })
# --- 1 FPS RATE LIMIT ---
# ensures this specific camera thread only loops once per second
elapsed = time.time() - now
time.sleep(max(0, 1.0 - elapsed))
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Grid View Generator # Grid View Generator
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -293,6 +298,7 @@ def serve_alert_image(filename): return send_from_directory("alerts", filename)
if __name__ == "__main__": if __name__ == "__main__":
for cam in CAMERAS: threading.Thread(target=_process_stream, args=(cam,), daemon=True).start() for cam in CAMERAS: threading.Thread(target=_process_stream, args=(cam,), daemon=True).start()
time.sleep(1)
threading.Thread(target=_update_grid_frame, daemon=True).start() threading.Thread(target=_update_grid_frame, daemon=True).start()
print("\n Grid View Dashboard → http://localhost:5000\n") print("\n Grid View Dashboard → http://localhost:5000\n")
app.run(host="0.0.0.0", port=5000, debug=False, threaded=True) app.run(host="0.0.0.0", port=5000, debug=False, threaded=True)