Categories
code opencv python video

[Python] OpenCV capturing from a v4l2 device

A python snippet on capturing from a v4l2 camera into OpenCV

I tried to set the capture format on a webcam from OpenCV’s cv2.VideoCapture and ran into a problem: it’s using the wrong IOCTL command.
So I used python-v4l2capture to get images from the device, which allows more control.
Here is the gist:

Enjoy!
Roy

One reply on “[Python] OpenCV capturing from a v4l2 device”

Thank you Roy! This saves me a lota trouble.
For some reason, the frame is always None in my case. I am using a ubuntu machine with one on board webcam.

Leave a Reply

Your email address will not be published. Required fields are marked *