From 4d9825bb1d6c8965a3685ded0e5b016a4d7b9c32 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Wed, 21 May 2025 16:06:16 +0200 Subject: [PATCH] fix(ci): change default opencv backend --- lerobot/common/cameras/utils.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lerobot/common/cameras/utils.py b/lerobot/common/cameras/utils.py index d95703da5..72f1dd3eb 100644 --- a/lerobot/common/cameras/utils.py +++ b/lerobot/common/cameras/utils.py @@ -46,28 +46,26 @@ def make_cameras_from_configs(camera_configs: dict[str, CameraConfig]) -> dict[s return cameras -def get_cv2_rotation(rotation: Cv2Rotation) -> int: +def get_cv2_rotation(rotation: Cv2Rotation) -> int | None: import cv2 - available_rotation_dict = { - Cv2Rotation.ROTATE_270: cv2.ROTATE_90_COUNTERCLOCKWISE, - Cv2Rotation.ROTATE_90: cv2.ROTATE_90_CLOCKWISE, - Cv2Rotation.ROTATE_180: cv2.ROTATE_180, - } - - return available_rotation_dict.get(rotation) + if rotation == Cv2Rotation.ROTATE_90: + return cv2.ROTATE_90_CLOCKWISE + elif rotation == Cv2Rotation.ROTATE_180: + return cv2.ROTATE_180 + elif rotation == Cv2Rotation.ROTATE_270: + return cv2.ROTATE_90_COUNTERCLOCKWISE + else: + return None def get_cv2_backend() -> int: import cv2 - available_cv2_backends = { - "Linux": cv2.CAP_V4L2, - "Windows": cv2.CAP_AVFOUNDATION, - "Darwin": cv2.CAP_ANY, - } - - return available_cv2_backends.get(platform.system(), cv2.CAP_V4L2) + if platform.system() == "Windows": + return cv2.CAP_AVFOUNDATION + else: + return cv2.CAP_ANY def save_image(img_array: np.ndarray, camera_index: int, frame_index: int, images_dir: Path):