fix(ci): change default opencv backend

This commit is contained in:
Steven Palma
2025-05-21 16:06:16 +02:00
parent 47d5008407
commit 4d9825bb1d

View File

@@ -46,28 +46,26 @@ def make_cameras_from_configs(camera_configs: dict[str, CameraConfig]) -> dict[s
return cameras return cameras
def get_cv2_rotation(rotation: Cv2Rotation) -> int: def get_cv2_rotation(rotation: Cv2Rotation) -> int | None:
import cv2 import cv2
available_rotation_dict = { if rotation == Cv2Rotation.ROTATE_90:
Cv2Rotation.ROTATE_270: cv2.ROTATE_90_COUNTERCLOCKWISE, return cv2.ROTATE_90_CLOCKWISE
Cv2Rotation.ROTATE_90: cv2.ROTATE_90_CLOCKWISE, elif rotation == Cv2Rotation.ROTATE_180:
Cv2Rotation.ROTATE_180: cv2.ROTATE_180, return cv2.ROTATE_180
} elif rotation == Cv2Rotation.ROTATE_270:
return cv2.ROTATE_90_COUNTERCLOCKWISE
return available_rotation_dict.get(rotation) else:
return None
def get_cv2_backend() -> int: def get_cv2_backend() -> int:
import cv2 import cv2
available_cv2_backends = { if platform.system() == "Windows":
"Linux": cv2.CAP_V4L2, return cv2.CAP_AVFOUNDATION
"Windows": cv2.CAP_AVFOUNDATION, else:
"Darwin": cv2.CAP_ANY, return cv2.CAP_ANY
}
return available_cv2_backends.get(platform.system(), cv2.CAP_V4L2)
def save_image(img_array: np.ndarray, camera_index: int, frame_index: int, images_dir: Path): def save_image(img_array: np.ndarray, camera_index: int, frame_index: int, images_dir: Path):