diff --git a/lerobot/common/cameras/opencv/camera_opencv.py b/lerobot/common/cameras/opencv/camera_opencv.py index eda86eb12..9951cfb14 100644 --- a/lerobot/common/cameras/opencv/camera_opencv.py +++ b/lerobot/common/cameras/opencv/camera_opencv.py @@ -125,9 +125,9 @@ class OpenCVCamera(Camera): if self.height and self.width: if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: - self.prerotated_width, self.prerotated_height = self.height, self.width + self.capture_width, self.capture_height = self.height, self.width else: - self.prerotated_width, self.prerotated_height = self.width, self.height + self.capture_width, self.capture_height = self.width, self.height def __str__(self) -> str: return f"{self.__class__.__name__}({self.index_or_path})" @@ -208,10 +208,10 @@ class OpenCVCamera(Camera): if self.width is None or self.height is None: if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: self.width, self.height = default_height, default_width - self.prerotated_width, self.prerotated_height = default_width, default_height + self.capture_width, self.capture_height = default_width, default_height else: self.width, self.height = default_width, default_height - self.prerotated_width, self.prerotated_height = default_width, default_height + self.capture_width, self.capture_height = default_width, default_height logger.info(f"Capture width set to camera default: {self.width}.") logger.info(f"Capture height set to camera default: {self.height}.") else: @@ -236,25 +236,25 @@ class OpenCVCamera(Camera): def _validate_width_and_height(self) -> None: """Validates and sets the camera's frame capture width and height.""" - success = self.videocapture.set(cv2.CAP_PROP_FRAME_WIDTH, float(self.prerotated_width)) + success = self.videocapture.set(cv2.CAP_PROP_FRAME_WIDTH, float(self.capture_width)) actual_width = int(round(self.videocapture.get(cv2.CAP_PROP_FRAME_WIDTH))) - if not success or self.prerotated_width != actual_width: + if not success or self.capture_width != actual_width: logger.warning( - f"Requested capture width {self.prerotated_width} for {self}, but camera reported {actual_width} (set success: {success})." + f"Requested capture width {self.capture_width} for {self}, but camera reported {actual_width} (set success: {success})." ) raise RuntimeError( - f"Failed to set requested capture width {self.prerotated_width} for {self}. Actual value: {actual_width}." + f"Failed to set requested capture width {self.capture_width} for {self}. Actual value: {actual_width}." ) logger.debug(f"Capture width set to {actual_width} for {self}.") - success = self.videocapture.set(cv2.CAP_PROP_FRAME_HEIGHT, float(self.prerotated_height)) + success = self.videocapture.set(cv2.CAP_PROP_FRAME_HEIGHT, float(self.capture_height)) actual_height = int(round(self.videocapture.get(cv2.CAP_PROP_FRAME_HEIGHT))) - if not success or self.prerotated_height != actual_height: + if not success or self.capture_height != actual_height: logger.warning( - f"Requested capture height {self.prerotated_height} for {self}, but camera reported {actual_height} (set success: {success})." + f"Requested capture height {self.capture_height} for {self}, but camera reported {actual_height} (set success: {success})." ) raise RuntimeError( - f"Failed to set requested capture height {self.prerotated_height} for {self}. Actual value: {actual_height}." + f"Failed to set requested capture height {self.capture_height} for {self}. Actual value: {actual_height}." ) logger.debug(f"Capture height set to {actual_height} for {self}.") @@ -387,9 +387,9 @@ class OpenCVCamera(Camera): h, w, c = image.shape - if h != self.prerotated_height or w != self.prerotated_width: + if h != self.capture_height or w != self.capture_width: raise RuntimeError( - f"Captured frame dimensions ({h}x{w}) do not match configured capture dimensions ({self.prerotated_height}x{self.prerotated_width}) for {self}." + f"Captured frame dimensions ({h}x{w}) do not match configured capture dimensions ({self.capture_height}x{self.capture_width}) for {self}." ) processed_image = image diff --git a/lerobot/common/cameras/realsense/camera_realsense.py b/lerobot/common/cameras/realsense/camera_realsense.py index c39e34698..e97dd5615 100644 --- a/lerobot/common/cameras/realsense/camera_realsense.py +++ b/lerobot/common/cameras/realsense/camera_realsense.py @@ -137,9 +137,9 @@ class RealSenseCamera(Camera): if self.height and self.width: if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: - self.prerotated_width, self.prerotated_height = self.height, self.width + self.capture_width, self.capture_height = self.height, self.width else: - self.prerotated_width, self.prerotated_height = self.width, self.height + self.capture_width, self.capture_height = self.width, self.height def __str__(self) -> str: return f"{self.__class__.__name__}({self.serial_number})" @@ -269,17 +269,17 @@ class RealSenseCamera(Camera): if self.width and self.height and self.fps: logger.debug( - f"Requesting Color Stream: {self.prerotated_width}x{self.prerotated_height} @ {self.fps} FPS, Format: {rs.format.rgb8}" + f"Requesting Color Stream: {self.capture_width}x{self.capture_height} @ {self.fps} FPS, Format: {rs.format.rgb8}" ) rs_config.enable_stream( - rs.stream.color, self.prerotated_width, self.prerotated_height, rs.format.rgb8, self.fps + rs.stream.color, self.capture_width, self.capture_height, rs.format.rgb8, self.fps ) if self.use_depth: logger.debug( - f"Requesting Depth Stream: {self.prerotated_width}x{self.prerotated_height} @ {self.fps} FPS, Format: {rs.format.z16}" + f"Requesting Depth Stream: {self.capture_width}x{self.capture_height} @ {self.fps} FPS, Format: {rs.format.z16}" ) rs_config.enable_stream( - rs.stream.depth, self.prerotated_width, self.prerotated_height, rs.format.z16, self.fps + rs.stream.depth, self.capture_width, self.capture_height, rs.format.z16, self.fps ) else: logger.debug(f"Requesting Color Stream: Default settings, Format: {rs.stream.color}") @@ -319,10 +319,10 @@ class RealSenseCamera(Camera): if self.width is None or self.height is None: if self.rotation in [cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE]: self.width, self.height = actual_height, actual_width - self.prerotated_width, self.prerotated_height = actual_width, actual_height + self.capture_width, self.capture_height = actual_width, actual_height else: self.width, self.height = actual_width, actual_height - self.prerotated_width, self.prerotated_height = actual_width, actual_height + self.capture_width, self.capture_height = actual_width, actual_height logger.info(f"Capture width set to camera default: {self.width}.") logger.info(f"Capture height set to camera default: {self.height}.") else: @@ -349,21 +349,21 @@ class RealSenseCamera(Camera): actual_width = int(round(stream.width())) actual_height = int(round(stream.height())) - if self.prerotated_width != actual_width: + if self.capture_width != actual_width: logger.warning( - f"Requested capture width {self.prerotated_width} for {self}, but camera reported {actual_width}." + f"Requested capture width {self.capture_width} for {self}, but camera reported {actual_width}." ) raise RuntimeError( - f"Failed to set requested capture width {self.prerotated_width} for {self}. Actual value: {actual_width}." + f"Failed to set requested capture width {self.capture_width} for {self}. Actual value: {actual_width}." ) logger.debug(f"Capture width set to {actual_width} for {self}.") - if self.prerotated_height != actual_height: + if self.capture_height != actual_height: logger.warning( - f"Requested capture height {self.prerotated_height} for {self}, but camera reported {actual_height}." + f"Requested capture height {self.capture_height} for {self}, but camera reported {actual_height}." ) raise RuntimeError( - f"Failed to set requested capture height {self.prerotated_height} for {self}. Actual value: {actual_height}." + f"Failed to set requested capture height {self.capture_height} for {self}. Actual value: {actual_height}." ) logger.debug(f"Capture height set to {actual_height} for {self}.") @@ -485,9 +485,9 @@ class RealSenseCamera(Camera): else: h, w, _c = image.shape - if h != self.prerotated_height or w != self.prerotated_width: + if h != self.capture_height or w != self.capture_width: raise RuntimeError( - f"Captured frame dimensions ({h}x{w}) do not match configured capture dimensions ({self.prerotated_height}x{self.prerotated_width}) for {self}." + f"Captured frame dimensions ({h}x{w}) do not match configured capture dimensions ({self.capture_height}x{self.capture_width}) for {self}." ) processed_image = image