diff --git a/lerobot/common/cameras/opencv/camera_opencv.py b/lerobot/common/cameras/opencv/camera_opencv.py index d68f419d6..7a2f1b324 100644 --- a/lerobot/common/cameras/opencv/camera_opencv.py +++ b/lerobot/common/cameras/opencv/camera_opencv.py @@ -124,10 +124,9 @@ class OpenCVCamera(Camera): self.backend: int = get_cv2_backend() if self.height and self.width: + self.capture_width, self.capture_height = self.width, self.height if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: self.capture_width, self.capture_height = self.height, self.width - else: - self.capture_width, self.capture_height = self.width, self.height def __str__(self) -> str: return f"{self.__class__.__name__}({self.index_or_path})" @@ -206,12 +205,11 @@ class OpenCVCamera(Camera): default_height = int(round(self.videocapture.get(cv2.CAP_PROP_FRAME_HEIGHT))) if self.width is None or self.height is None: + self.width, self.height = default_width, default_height + self.capture_width, self.capture_height = default_width, default_height if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: self.width, self.height = default_height, default_width self.capture_width, self.capture_height = default_width, default_height - else: - self.width, self.height = default_width, default_height - self.capture_width, self.capture_height = default_width, default_height else: self._validate_width_and_height() diff --git a/lerobot/common/cameras/realsense/camera_realsense.py b/lerobot/common/cameras/realsense/camera_realsense.py index 1ef23de91..2bcbee75c 100644 --- a/lerobot/common/cameras/realsense/camera_realsense.py +++ b/lerobot/common/cameras/realsense/camera_realsense.py @@ -138,10 +138,9 @@ class RealSenseCamera(Camera): self.rotation: int | None = get_cv2_rotation(config.rotation) if self.height and self.width: + self.capture_width, self.capture_height = self.width, self.height if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: self.capture_width, self.capture_height = self.height, self.width - else: - self.capture_width, self.capture_height = self.width, self.height def __str__(self) -> str: return f"{self.__class__.__name__}({self.serial_number})"