Compare commits

...

2 Commits

Author SHA1 Message Date
ahmedmujtaba-gif a7b7a571c3 Server 0.6 2026-04-17 13:26:20 +05:00
ahmedmujtaba-gif dcac92d7e5 Server 0.5 2026-04-16 19:29:08 +05:00
1 changed files with 5 additions and 2 deletions

View File

@ -127,8 +127,11 @@ def _process_stream(camera):
if cap is None: if cap is None:
cap = cv2.VideoCapture(rtsp_url) cap = cv2.VideoCapture(rtsp_url)
if not cap.isOpened(): if not cap.isOpened():
print(f"[ERROR] {camera['name']} (IP: {camera['ip']}) failed to connect. Check if 401 Unauthorized or 403 Forbidden.")
with lock: state["cameras"][cam_id]["status"] = "error" with lock: state["cameras"][cam_id]["status"] = "error"
time.sleep(5); cap = None; continue time.sleep(10); cap = None; continue
print(f"[SUCCESS] {camera['name']} (IP: {camera['ip']}) connected and streaming over TCP.")
with lock: state["cameras"][cam_id]["status"] = "live" with lock: state["cameras"][cam_id]["status"] = "live"
ret, frame = cap.read() ret, frame = cap.read()
@ -298,7 +301,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) time.sleep(1.5)
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)