Free Motion Capture for Everyone πβ¨
TypeScript
cameras are fun :D
Jon32def4b61fb1
diff --git a/requirements.txt b/requirements.txtindex 12cd626c..04ce3d77 100644--- a/requirements.txt+++ b/requirements.txt@@ -2,7 +2,7 @@ aniposelib==0.4.3h5py>=3.1.0imutils~=0.5.4matplotlib~=3.1.3-mediapipe==0.8.8+# mediapipe==0.8.8opencv-contrib-python==4.5.5.62pandas~=1.2.5rich~=10.4.0diff --git a/src/core_processor/board_detection/detect.py b/src/core_processor/board_detection/detect.pyindex e8274472..c2bc2fed 100644--- a/src/core_processor/board_detection/detect.py+++ b/src/core_processor/board_detection/detect.py@@ -1,12 +1,23 @@import loggingimport cv2+import numpy as np+from aiomultiprocess import Processfrom aiomultiprocess.types import Queuefrom src.core_processor.processor import ImagePayload-logger = logging.getLogger(__name__)++from rich import inspect+++# aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_4X4_250)+# charuco_length = 7+# charuco_width = 5++# board = cv2.aruco.CharucoBoard_create(charuco_length, charuco_width, 1, .8, aruco_dict)+# num_charuco_corners = (charuco_length-1) * (charuco_width-1)class BoardDetection:@@ -17,47 +28,62 @@ class BoardDetection:await p.join()async def process(self, queue: Queue):+ logger = logging.getLogger(__name__)while True:+ message = Nonetry:message = queue.get(timeout=1) # type: ImagePayload- frames = message.frames- for f in frames:- cv2.imshow(str(f.port_number), f.image)- exit_key = cv2.waitKey(1)- if exit_key == 27:- breakexcept Exception as e:- print(e)- logger.error(e)-- # def detect_charuco_board(self, image):- # """- # Charuco base pose estimation.- # more-or-less copied from - https://mecaruco2.readthedocs.io/en/latest/notebooks_rst/Aruco- # /sandbox/ludovic/aruco_calibration_rotation.html- # """- # charuco_corners = []- # charuco_ids = []- #- # # SUB PIXEL CORNER DETECTION CRITERION- # criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.00001)- #- # gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)- # aruco_square_corners, aruco_square_ids, rejectedImgPoints = cv2.aruco.detectMarkers(gray,- # aruco_dict)- #- # if len(aruco_square_corners) > 0:- # # SUB PIXEL DETECTION- # for this_corner in aruco_square_corners:- # cv2.cornerSubPix(gray, this_corner,- # winSize=(3, 3),- # zeroZone=(-1, -1),- # criteria=criteria)- # res2 = cv2.aruco.interpolateCornersCharuco(aruco_square_corners, aruco_square_ids, gray,- # board)- #- # if res2[1] is not None and res2[2] is not None and len(res2[1]) > 3:- # charuco_corners = res2[1]- # charuco_ids = res2[2]- #- # return charuco_corners, charuco_ids, aruco_square_corners, aruco_square_ids+ pass+ print('got message from the queue')++++ if not message:+ continue++ frames = message.frames+ print(f'got image of shape {f.image.shape}')++ for f in frames:+ # charuco_corners, charuco_ids, aruco_square_corners, aruco_square_ids = self.detect_charuco_board(f.image)+ # cv2.polylines(f.image, np.int32([charuco_corners]), True, (0,100,255), 2)++ cv2.imshow(str(f.port_number), f.image)+ exit_key = cv2.waitKey(1)+ if exit_key == 27:+ break+++ def detect_charuco_board(self, image):+ """+ Charuco base pose estimation.+ more-or-less copied from - https://mecaruco2.readthedocs.io/en/latest/notebooks_rst/Aruco+ /sandbox/ludovic/aruco_calibration_rotation.html+ """+ charuco_corners = []+ charuco_ids = []++ # SUB PIXEL CORNER DETECTION CRITERION+ criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.00001)++ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)+ aruco_square_corners, aruco_square_ids, rejectedImgPoints = cv2.aruco.detectMarkers(gray,+ aruco_dict)++ if len(aruco_square_corners) > 0:+ # SUB PIXEL DETECTION+ for this_corner in aruco_square_corners:+ cv2.cornerSubPix(gray, this_corner,+ winSize=(3, 3),+ zeroZone=(-1, -1),+ criteria=criteria)+ res2 = cv2.aruco.interpolateCornersCharuco(aruco_square_corners, aruco_square_ids, gray,+ board)++ if res2[1] is not None and res2[2] is not None and len(res2[1]) > 3:+ charuco_corners = res2[1]+ charuco_ids = res2[2]++ return charuco_corners, charuco_ids, aruco_square_corners, aruco_square_ids+diff --git a/src/core_processor/processor.py b/src/core_processor/processor.pyindex 0a9a2c53..f1b2011c 100644--- a/src/core_processor/processor.py+++ b/src/core_processor/processor.py@@ -53,6 +53,7 @@ class CameraCaptureProcess:image_list: List[FramePayload] = []for cv_cam in cv_cams:success, image, timestamp = cv_cam.get_next_frame()+if not success:continueif image is None:@@ -67,4 +68,4 @@ class CameraCaptureProcess:_queue.put(ImagePayload(frames=image_list))- # _logger.info("Im printing stuff")+ _logger.info("Im printing stuff")