Skip to content

Commit 868afa6

Browse files
committed
Merge branch 'user/pepijn/2025_04_10_fix_camera_rotation' of https://github.com/huggingface/lerobot into user/pepijn/2025_04_10_fix_camera_rotation
2 parents b76c86d + e2c08a4 commit 868afa6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

lerobot/common/robot_devices/cameras/intelrealsense.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def __init__(
231231

232232
# If rotated by ±90, swap width and height.
233233
if config.rotation in [-90, 90]:
234-
self.width = config.height
235-
self.height = config.width
234+
self.width = config.height
235+
self.height = config.width
236236
else:
237237
self.width = config.width
238238
self.height = config.height
@@ -296,13 +296,17 @@ def connect(self):
296296

297297
if self.fps and self.capture_width and self.capture_height:
298298
# TODO(rcadene): can we set rgb8 directly?
299-
config.enable_stream(rs.stream.color, self.capture_width, self.capture_height, rs.format.rgb8, self.fps)
299+
config.enable_stream(
300+
rs.stream.color, self.capture_width, self.capture_height, rs.format.rgb8, self.fps
301+
)
300302
else:
301303
config.enable_stream(rs.stream.color)
302304

303305
if self.use_depth:
304306
if self.fps and self.capture_width and self.capture_height:
305-
config.enable_stream(rs.stream.depth, self.capture_width, self.capture_height, rs.format.z16, self.fps)
307+
config.enable_stream(
308+
rs.stream.depth, self.capture_width, self.capture_height, rs.format.z16, self.fps
309+
)
306310
else:
307311
config.enable_stream(rs.stream.depth)
308312

lerobot/common/robot_devices/cameras/opencv.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ def __init__(self, config: OpenCVCameraConfig):
250250

251251
# If rotated by ±90, swap width and height.
252252
if config.rotation in [-90, 90]:
253-
self.width = config.height
254-
self.height = config.width
253+
self.width = config.height
254+
self.height = config.width
255255
else:
256256
self.width = config.width
257257
self.height = config.height
@@ -349,11 +349,15 @@ def connect(self):
349349
raise OSError(
350350
f"Can't set {self.fps=} for OpenCVCamera({self.camera_index}). Actual value is {actual_fps}."
351351
)
352-
if self.capture_width is not None and not math.isclose(self.capture_width, actual_width, rel_tol=1e-3):
352+
if self.capture_width is not None and not math.isclose(
353+
self.capture_width, actual_width, rel_tol=1e-3
354+
):
353355
raise OSError(
354356
f"Can't set {self.capture_width=} for OpenCVCamera({self.camera_index}). Actual value is {actual_width}."
355357
)
356-
if self.capture_height is not None and not math.isclose(self.capture_height, actual_height, rel_tol=1e-3):
358+
if self.capture_height is not None and not math.isclose(
359+
self.capture_height, actual_height, rel_tol=1e-3
360+
):
357361
raise OSError(
358362
f"Can't set {self.capture_height=} for OpenCVCamera({self.camera_index}). Actual value is {actual_height}."
359363
)

0 commit comments

Comments
 (0)