OpenCV cv2.VideoCapture not working with Arducam quadcam on Raspberry Pi 4

Hi everyone, I’m trying to get an Arducam quadcam working on a Raspberry Pi 4 with plain OpenCV and I’m stuck. I’ve been using picam2 for capture so far and I’m moving everything over to OpenCV, and I assumed the quadcam would just work with cv2.VideoCapture.

Right now I have 2 cameras connected on RX0 and RX3 (the other 2 might have cable issues, not sure yet). libcamera-hello sees the 2 cameras fine. But when I try OpenCV:

cv2.VideoCapture(0)  # does not return, hangs
cap = cv2.VideoCapture(1)
ret, frame = cap.read()  # ret = false

So VideoCapture(0) just hangs and never comes back. VideoCapture(1) returns a cap, but read() gives ret = false every time.

I’m not even sure which index I’m supposed to use with cv2.VideoCapture for this setup. Also I’m on Raspberry Pi OS Bookworm, and I’m a bit worried about Bookworm compatibility for the fisheye camera option. I was looking at the Arducam 5MP Ultra Wide Angle Fisheye Lens OV5647 too — does anyone know the release date, if there are newer models, and whether it works on Bookworm?

test.jpg

Welcome to the forum. Before digging into the software side, can you verify whether the error changes if you swap the cables? With two of the cameras possibly having cable issues, that’s worth ruling out first.

On the OpenCV side, for MIPI cameras on the Raspberry Pi the typical route is not to call cv2.VideoCapture directly. We have a Picamera2 + OpenCV example that captures from the camera with Picamera2 and then shows/processes the frames with OpenCV. You can refer to it here:

So OpenCV can be used with the MIPI camera, but through a Picamera2-based capture layer rather than by opening the camera directly with cv2.VideoCapture.

Thanks, but I should have been clearer — picamera already works for me. I need cv2.VideoCapture specifically to work because I’m moving the whole pipeline to OpenCV. That’s the part that’s broken.

rpicam -t 0 shows the 2 cameras fine on RX0 and RX3. But:

cv2.VideoCapture(0)  # does not return, hangs
cap = cv2.VideoCapture(1)
ret, frame = cap.read()  # ret = false

So is the Arducam quadcam actually compatible with OpenCV 4, or not? I don’t want to keep fighting this if it’s a known limitation.

To be direct: you cannot get image data from a MIPI camera on the Raspberry Pi directly through OpenCV. That’s not specific to this board — OpenCV direct capture works with UVC (USB) cameras. If you want to use cv2.VideoCapture directly, a UVC camera is the path.

For a MIPI camera like the quadcam, the supported approach is to use Picamera2 to capture the image data, and then show or process those frames with OpenCV. So the capture layer is Picamera2, and OpenCV handles the display/processing part.

Did Arducam actually test the camarray in the lab and confirm it can’t be made to work with OpenCV? I’ve spent many hours on this. I need to know whether the issue is with the camera or with OpenCV, and whether this limitation is documented anywhere — I haven’t seen it called out. Also, did OpenCV ever work directly with Arducam cameras in the past? If it’s an OpenCV limitation, I’ll escalate it to the OpenCV side.

Just to clarify the distinction: the camarray / MIPI camera can absolutely still be used with OpenCV — OpenCV just can’t obtain the image data directly from the camera. Once frames are provided via libcamera/picamera2, OpenCV can show and process the stream without issue.

This comes down to how Raspberry Pi OS works now: camera management goes through libcamera (picamera2), and OpenCV itself does not directly interface with MIPI cameras out of the box. It’s not something specific to the camarray.

For the MIPI camera, use the libcamera/picamera2 tools to interface with the camera, retrieve the frames, and then hand them to OpenCV for processing. Meanwhile, Arducam UVC (USB) cameras do work with OpenCV directly, all the time.

Okay, so the OpenCV issue is specific to the camarray on the Pi, not all Arducam cameras in general — I get that USB cameras work directly. I just never saw any documentation stating that OpenCV doesn’t support Pi cameras directly, which is why I went down this rabbit hole. I’ll take this over to the OpenCV side. Thanks for the clarification.