From a3ddba24548ae5d836cf280a7787e4bcd8e44ec7 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Fri, 31 Jul 2026 17:13:32 +0200 Subject: [PATCH] feat(cameras): prefer MJPG when fourcc unspecified in ZMQ (#4277) * feat(cameras): prefer MJPG when fourcc unspecified; allow fourcc in ZMQ image server With no fourcc set, OpenCV's V4L2 auto-negotiation selects uncompressed YUYV when the camera offers it: ~16x the USB bandwidth of MJPG for identical frames, which silently caps the frame rate on shared USB 2.0 buses (e.g. a Raspberry Pi with multiple cameras). OpenCVCamera now prefers MJPG when config.fourcc is None: it requests MJPG and keeps it only if the camera reports support (read-back), falling back to the camera's own negotiation otherwise. An explicit config.fourcc always takes precedence, so opting out is fourcc="YUYV". The preference mirrors the existing pre/post size-and-fps ordering to preserve the Windows DSHOW FOURCC-override handling. Also adds a fourcc passthrough to the ZMQ image server, which previously could not request a pixel format at all. Behavior change: cameras that relied on implicit uncompressed capture now receive camera-side JPEG unless fourcc is set explicitly. * chore(cameras): address feedback --------- Co-authored-by: Xingdong Zuo <18168681+zuoxingdong@users.noreply.github.com> --- src/lerobot/cameras/zmq/image_server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lerobot/cameras/zmq/image_server.py b/src/lerobot/cameras/zmq/image_server.py index b8b6f8e74..dac1d06be 100644 --- a/src/lerobot/cameras/zmq/image_server.py +++ b/src/lerobot/cameras/zmq/image_server.py @@ -102,6 +102,7 @@ class ImageServer: fps=self.fps, width=shape[1], height=shape[0], + fourcc=cfg.get("fourcc", "MJPG"), color_mode=ColorMode.RGB, ) camera = OpenCVCamera(cam_config)