Free Motion Capture for Everyone πβ¨
TypeScript
safety
Endurance Idehen4c7e22e2b225
diff --git a/src/cameras/frame_grabber.py b/src/cameras/frame_grabber.pyindex 06240152..3e1398e3 100644--- a/src/cameras/frame_grabber.py+++ b/src/cameras/frame_grabber.py@@ -20,6 +20,7 @@ class FrameThread(threading.Thread):self._num_frames_processed = 0self._elapsed = 0self._frame: FramePayload = FramePayload()+ self.setDaemon(True)if save_video:self._writer = writerdiff --git a/src/cameras/opencv_camera.py b/src/cameras/opencv_camera.pyindex 30ffa8c7..8fcae446 100644--- a/src/cameras/opencv_camera.py+++ b/src/cameras/opencv_camera.py@@ -109,5 +109,8 @@ class OpenCVCamera:return FramePayload(False, None, None)def close(self):+ logger.info("Closing camera {}".format(self._name))+ if self._running_thread:+ self._running_thread.stop()self._opencv_video_capture_object.release()logger.info("Closed camera {}".format(self._name))diff --git a/src/core_processor/board_detection/board_detection.py b/src/core_processor/board_detection/board_detection.pyindex 9bb09f34..49e2439f 100644--- a/src/core_processor/board_detection/board_detection.py+++ b/src/core_processor/board_detection/board_detection.py@@ -1,6 +1,6 @@+import asyncioimport loggingimport traceback-from queue import Queueimport cv2import numpy as np@@ -28,6 +28,8 @@ class BoardDetection:if cb:await cb(image, cv_cam.webcam_id_as_str)except:+ for cv_cam in cv_cams:+ cv_cam.close()traceback.print_exc()async def process(self):@@ -41,16 +43,21 @@ class BoardDetection:cv_cam.start_frame_capture(save_video=True)while True:- exit_key = cv2.waitKey(1)- if exit_key == 27:- cv2.destroyAllWindows()+ try:+ exit_key = cv2.waitKey(1)+ if exit_key == 27:+ cv2.destroyAllWindows()+ for cv_cam in cv_cams:+ cv_cam.close()+ break+ for cv_cam in cv_cams:+ frame = self._process_single_cam_frame(cv_cam)+ if frame is not None:+ cv2.imshow(cv_cam.webcam_id_as_str, frame)+ except:for cv_cam in cv_cams:cv_cam.close()- break- for cv_cam in cv_cams:- frame = self._process_single_cam_frame(cv_cam)- if frame is not None:- cv2.imshow(cv_cam.webcam_id_as_str, frame)+ cv2.destroyAllWindows()def _process_single_cam_frame(self, cv_cam):success, frame, timestamp = cv_cam.latest_frame@@ -77,6 +84,4 @@ class BoardDetection:if __name__ == "__main__":## Jon, Run me to easily start a charuco board detect run- # asyncio.run(BoardDetection().process())- q = Queue()- BoardDetection().process_as_frame_loop(q)+ asyncio.run(BoardDetection().process())