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
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):