chore(cameras): refactor utility function dictionary fetching style

This commit is contained in:
Steven Palma
2025-05-20 16:43:58 +02:00
parent 525cd68e62
commit ab7565a666

View File

@@ -49,21 +49,25 @@ def make_cameras_from_configs(camera_configs: dict[str, CameraConfig]) -> dict[s
def get_cv2_rotation(rotation: Cv2Rotation) -> int: def get_cv2_rotation(rotation: Cv2Rotation) -> int:
import cv2 import cv2
return { available_rotation_dict = {
Cv2Rotation.ROTATE_270: cv2.ROTATE_90_COUNTERCLOCKWISE, Cv2Rotation.ROTATE_270: cv2.ROTATE_90_COUNTERCLOCKWISE,
Cv2Rotation.ROTATE_90: cv2.ROTATE_90_CLOCKWISE, Cv2Rotation.ROTATE_90: cv2.ROTATE_90_CLOCKWISE,
Cv2Rotation.ROTATE_180: cv2.ROTATE_180, Cv2Rotation.ROTATE_180: cv2.ROTATE_180,
}.get(rotation) }
return available_rotation_dict.get(rotation)
def get_cv2_backend() -> int: def get_cv2_backend() -> int:
import cv2 import cv2
return { available_cv2_backends = {
"Linux": cv2.CAP_DSHOW, "Linux": cv2.CAP_DSHOW,
"Windows": cv2.CAP_AVFOUNDATION, "Windows": cv2.CAP_AVFOUNDATION,
"Darwin": cv2.CAP_ANY, "Darwin": cv2.CAP_ANY,
}.get(platform.system(), cv2.CAP_V4L2) }
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):