I'm trying to use Docker for one of our projects which uses OpenCV to process webcam feed (Python). But I can't seem to get access to the webcam within docker, here's the code which I use to test webcam access:
python -c "import cv2;print(cv2.VideoCapture(0).isOpened())"
And here's what I tried so far,
docker run --device=/dev/video0 -it rec bash
docker run --privileged --device=/dev/video0 -it rec bash
sudo docker run --privileged --device=/dev/video0:/dev/video0 -it rec bash
All of these return False
, what am I doing wrong?
cv2.VideoCapture(0)
is actually/dev/video0
. Have you tried video1 and so on? Which Linux is this?/dev/video0
actually known to work on the host? Has it been tested with something like VLC (vlc v4l2:///dev/video0
)? I know it also may not matter, but for completeness sake it would be prudent to mention the versions of stuff involved and probably theDockerfile
you used to build therec
image.