Supported Camera Types
OpenCV Cameras
OpenCV cameras work with any device supported by OpenCV’s VideoCapture, including:- USB webcams
- Laptop built-in cameras
- Industrial cameras with V4L2 support (Linux)
- Video files for testing
Intel RealSense Cameras
RealSense cameras provide both color and depth sensing:- D400 series (D405, D415, D435, D455)
- SR300 series
- L500 series
Installation
OpenCV Camera Dependencies
OpenCV support is included by default with LeRobot:RealSense Camera Dependencies
For Intel RealSense cameras, install additional dependencies:Finding Cameras
Use the built-in camera discovery tools to identify connected cameras:Find OpenCV Cameras
Find RealSense Cameras
Configuration
OpenCV Camera Configuration
index_or_path: Camera index (e.g., 0, 1) or device path (e.g.,/dev/video4)fps: Frames per second (default: None, uses camera default)width,height: Resolution in pixels (default: None, uses camera default)color_mode:ColorMode.RGBorColorMode.BGR(default: RGB)rotation:NO_ROTATION,ROTATE_90_CLOCKWISE,ROTATE_90_COUNTERCLOCKWISE,ROTATE_180fourcc: Video format code (e.g., “MJPG”, “YUYV”, “H264”)warmup_s: Warmup time in seconds before first frame (default: 1)
/home/daytona/workspace/source/src/lerobot/cameras/opencv/configuration_opencv.py:23
RealSense Camera Configuration
serial_number_or_name: Unique serial number or camera namefps,width,height: Must all be set or all be None (uses camera defaults)use_depth: Enable depth stream (default: False)color_mode:ColorMode.RGBorColorMode.BGR(default: RGB)rotation: Same options as OpenCVwarmup_s: Warmup time in seconds (default: 1)
/home/daytona/workspace/source/src/lerobot/cameras/realsense/configuration_realsense.py:22
Basic Usage
Connecting to a Camera
Reading Frames
LeRobot cameras support three frame reading methods:1. Synchronous Read (Blocking)
Waits for the next frame from the camera:2. Asynchronous Read (Background Thread)
Reads from a background thread with timeout:3. Read Latest (Non-blocking)
Returns the most recent frame immediately:/home/daytona/workspace/source/src/lerobot/cameras/opencv/camera_opencv.py:351
Reading Depth (RealSense Only)
/home/daytona/workspace/source/src/lerobot/cameras/realsense/camera_realsense.py:322
Disconnecting
Advanced Usage
Multi-Camera Setup
High-Speed Capture with MJPEG
For higher frame rates, use Motion JPEG format:Continuous Capture Loop
Color Space Conversion
Camera Calibration
For robot applications requiring precise camera calibration:Linux-Specific Tips
Camera Permissions
Add your user to thevideo group:
Checking Camera Capabilities
Stable Camera Paths with udev
Create a udev rule for consistent device paths:/dev/camera-front instead of /dev/video0.
Troubleshooting
OpenCV Issues
Camera not found:- Run
lerobot-find-cameras opencvto list available cameras - Check camera is not in use by another application
- Try different camera indices (0, 1, 2, …)
- On Linux, check
/dev/video*permissions
- Try different
fourccformats (“MJPG” often faster than “YUYV”) - Reduce resolution
- Check USB bandwidth (use USB 3.0 ports)
- Close other applications using the camera
- Check
color_modesetting (RGB vs BGR) - Some cameras may need specific
fourccsettings
RealSense Issues
“No RealSense devices detected”:- Check USB connection (use USB 3.0 ports for best performance)
- Verify
pyrealsense2is installed:pip install pyrealsense2 - On Linux, check udev rules are installed:
sudo apt install librealsense2-dkms - Run
lerobot-find-cameras realsenseto verify detection
- Update firmware using Intel RealSense Viewer
- Download from: https://www.intelrealsense.com/developers/
- Ensure
use_depth=Truein configuration - Check that depth is supported at your resolution/FPS combination
- Try lower resolution or frame rate
- Depth sensing requires adequate lighting and non-reflective surfaces
Performance Tips
- Use MJPEG format for higher frame rates with USB cameras
- Reduce resolution if you don’t need high detail
- Use async_read() in high-frequency control loops
- Disable warmup for faster connection:
warmup_s=0(may cause initial frame drops) - Use background threads for multi-camera setups
- On Windows, set
OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS=0(done automatically)
References
- OpenCV Camera Source:
/home/daytona/workspace/source/src/lerobot/cameras/opencv/camera_opencv.py:1 - RealSense Camera Source:
/home/daytona/workspace/source/src/lerobot/cameras/realsense/camera_realsense.py:1 - OpenCV VideoCapture Documentation
- Intel RealSense SDK Documentation