diff --git a/src/lerobot/cameras/opencv/camera_opencv.py b/src/lerobot/cameras/opencv/camera_opencv.py index 89d5995f4..28c978d1c 100644 --- a/src/lerobot/cameras/opencv/camera_opencv.py +++ b/src/lerobot/cameras/opencv/camera_opencv.py @@ -208,11 +208,6 @@ class OpenCVCamera(Camera): if self.videocapture is None: raise DeviceNotConnectedError(f"{self} videocapture is not initialized") - if self.fps is None: - self.fps = self.videocapture.get(cv2.CAP_PROP_FPS) - else: - self._validate_fps() - default_width = int(round(self.videocapture.get(cv2.CAP_PROP_FRAME_WIDTH))) default_height = int(round(self.videocapture.get(cv2.CAP_PROP_FRAME_HEIGHT))) @@ -225,6 +220,11 @@ class OpenCVCamera(Camera): else: self._validate_width_and_height() + if self.fps is None: + self.fps = self.videocapture.get(cv2.CAP_PROP_FPS) + else: + self._validate_fps() + def _validate_fps(self) -> None: """Validates and sets the camera's frames per second (FPS)."""