Fix lerobot-find-cameras hang with Intel IPU6 (MIPI) cameras by forcing V4L2 on Linux#2657
Fix lerobot-find-cameras hang with Intel IPU6 (MIPI) cameras by forcing V4L2 on Linux#2657leonardogargani wants to merge 1 commit intohuggingface:mainfrom
lerobot-find-cameras hang with Intel IPU6 (MIPI) cameras by forcing V4L2 on Linux#2657Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an indefinite hang in lerobot-find-cameras on Linux systems with Intel IPU6 (MIPI) cameras by forcing OpenCV to use the V4L2 backend instead of FFmpeg when probing /dev/video* paths. The fix ensures consistent backend usage across all camera operations.
Key Changes:
- Modified
get_cv2_backend()to explicitly returnCAP_V4L2for Linux systems - Updated
find_cameras()to useget_cv2_backend()when creating VideoCapture instances for camera detection
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/lerobot/cameras/utils.py |
Added Linux-specific case to return CAP_V4L2 backend instead of CAP_ANY |
src/lerobot/cameras/opencv/camera_opencv.py |
Updated find_cameras() to use get_cv2_backend() when probing cameras |
The implementation looks solid and follows the existing pattern where self.backend = get_cv2_backend() is already used in the __init__ method (line 129) and then passed to cv2.VideoCapture() in the connect() method (line 163). The change ensures that camera discovery uses the same backend as camera initialization, which is the correct approach.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What this does
This PR fixes an indefinite hang in
lerobot-find-camerason Linux with Intel IPU6 cameras caused by OpenCV selecting the FFmpeg backend for/dev/video*paths.The fix forces the V4L2 backend when probing video devices on Linux while preserving existing behavior elsewhere.
Closes #2594.
How it was tested
The changes were tested on a Linux laptop equipped with an Intel IPU6 (MIPI) webcam.
mainbranch,lerobot-find-cameras opencvhangs indefinitely while probing/dev/video*.lerobot-find-cameras opencvcompletes successfully and lists the available camera devices.How to checkout & try?
To verify the fix, run:
On Linux, Windows, or macOS, and with any supported camera configuration (e.g., MIPI, USB webcam, RealSense), the command should complete without hanging and list all detected cameras.