Free Motion Capture for Everyone πβ¨
TypeScript
print elasped time per frame
Endurance Idehen14a2d792fb58
diff --git a/requirements.txt b/requirements.txtindex f3ab8ea7..62d5706a 100644--- a/requirements.txt+++ b/requirements.txt@@ -24,5 +24,6 @@ sqlalchemy==1.4.31singleton-decorator==1.0.0orjson==3.6.7aiomultiprocess==0.9.0-faster-fifo==1.3.0+# faster-fifo==1.3.0+# viztracer==0.14.5# Requirements for core-processordiff --git a/src/api/routes/camera/cam_data_ws.py b/src/api/routes/camera/cam_data_ws.pyindex 88579408..74e1cb6d 100644--- a/src/api/routes/camera/cam_data_ws.py+++ b/src/api/routes/camera/cam_data_ws.py@@ -4,6 +4,7 @@ import loggingimport cv2import orjsonfrom fastapi import APIRouter, WebSocket+from time import perf_counterfrom jon_scratch.opencv_camera import OpenCVCamera@@ -21,6 +22,7 @@ async def websocket_endpoint(websocket: WebSocket, webcam_id: str):try:while True:+ t1_start = perf_counter()success, image, timestamp = cam.get_next_frame()if not success:continue@@ -36,6 +38,8 @@ async def websocket_endpoint(websocket: WebSocket, webcam_id: str):}d = orjson.dumps(d)await websocket.send_bytes(d)+ t1_stop = perf_counter()+ print("Elapsed time per frame:", t1_stop-t1_start)except:logger.info(f"Camera {webcam_id} is now closed.")cam.close()diff --git a/src/core_processor/app_events/event_notify.py b/src/core_processor/app_events/event_notify.pyindex 69e69b50..78d40cfd 100644--- a/src/core_processor/app_events/event_notify.py+++ b/src/core_processor/app_events/event_notify.py@@ -1,4 +1,3 @@-import asyncioimport loggingimport multiprocessing@@ -16,12 +15,11 @@ class EventNotifier:async def notify_all_subscribers(self, queue: multiprocessing.Queue):while True:try:- message = queue.get(timeout=1)+ message = queue.get(timeout=.1)for worker in self._workers:await worker.process(message)except Exception as e:- print(e)- logger.error("Notifier dead")+ passdef _construct(self):return [sub() for sub in subscribers]diff --git a/src/core_processor/board_detection/detect.py b/src/core_processor/board_detection/detect.pyindex 57c3bcd4..62cea399 100644--- a/src/core_processor/board_detection/detect.py+++ b/src/core_processor/board_detection/detect.py@@ -9,4 +9,5 @@ class BoardDetection:passasync def process(self, message, *args, **kwargs):+ # logger.info(message)logger.info(message["timestamp"])diff --git a/src/core_processor/ws_connection.py b/src/core_processor/ws_connection.pyindex 96e06b0c..b5d74b60 100644--- a/src/core_processor/ws_connection.py+++ b/src/core_processor/ws_connection.py@@ -14,10 +14,8 @@ class WSConnection:async for websocket in websockets.connect(uri, max_size=None, ping_timeout=None):try:async for message in websocket:- # How expensive is it to parse a json string?as_json = orjson.loads(message)- logger.info(f"webcam_id: {webcam_id}, msg rcv")- queue.put(as_json, timeout=1)+ queue.put_nowait(as_json)except websockets.ConnectionClosed as e:logger.error(e)continue