Hi, quick question — can the Arducam 16MP autofocus camera be used with OpenCV in Python?
I’m on a Raspberry Pi with Python and cv2 installed. With a normal USB webcam I can just do:
cap = cv2.VideoCapture(2)
and everything works fine. But when I plug in the Arducam and try the exact same thing, it doesn’t work at all. It just… does nothing / no frames come out.
Short answer: yes, you can use the Arducam 16MP with OpenCV in Python, but not the way you’re doing it with cv2.VideoCapture(2).
The Arducam (16MP autofocus) isn’t exposed like a standard UVC webcam, so opening it through a plain OpenCV VideoCapture index the same way you would a USB webcam won’t work. Instead you need to go through picamera2.
Take a look at that and try running it — it shows how to grab frames from the camera and feed them into an OpenCV window. Can you let me know what happens when you run it?
Ok that makes sense, thanks. I’ll give the picamera2 example a shot.
One thing though — while poking around I noticed the autofocus is kind of off and the image keeps shifting brightness on its own. Is that also something I need to fix separately, or is it related?
Second, if you’re seeing the frame change per second because of auto-exposure and you actually want a still frame, switch to manual exposure mode with:
libcamera-still -t 0 --shutter value
where value is the exposure time — for example 500.
That helped a lot, the autofocus and exposure issues are looking much better now. Thanks.
So just to confirm the main thing: the reason cap = cv2.VideoCapture(2) never worked is that the Arducam isn’t being opened as a UVC device, right? I should always be using the picamera2 + OpenCV route instead?
Opening the Arducam camera with cv2.VideoCapture(index) doesn’t behave the same way as a standard USB webcam — it needs a picamera2-based approach instead of the plain OpenCV VideoCapture method. So don’t use the standard cv2.VideoCapture path with this camera.