I’m trying to access my Arducam cameras from Python but I can’t get anything to work. My setup is an Arducam CamArray HAT Kit (1MP 4 Quadrascopic Camera Bundle Kit, IMX219) on a Raspberry Pi 4 Model B (8GB RAM), running Raspberry Pi OS 64-bit with desktop and recommended software.
I started with the usual OpenCV approach:
Import cv2
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow('Display', frame)
if cv2.waitKey(1) & 0xFF && ord('q'):
break
cap.release()
cv2.destroyAllWindows()
But cv2.VideoCapture(0) doesn’t open the camera - I get no frames. I also tried running libcamera-still -t 0 --camera 0 and got an error (screenshot attached, I didn’t copy the text out of it).
What do I actually need to use these cameras from Python? Do I need extra libraries to access multiple cameras?
Thanks for the detailed info. Based on your hardware photo and description, you’re on a Raspberry Pi 4 Model B. One important thing about that board: the Pi 4 only has one CSI port, whereas the Pi 5 has two CSI ports. So a second Camarray HAT can’t be connected to the Pi 4.
On the OpenCV side, plain cv2.VideoCapture(0) won’t work for these cameras because the Camarray HAT runs through the libcamera/picamera2 stack, not the legacy interface OpenCV expects by default.
Can you post the exact text of the error you got from libcamera-still -t 0 --camera 0? That’ll help us figure out whether the camera is detected at all before we go further.
The libcamera-still error was only in a screenshot and I didn’t grab the text out of it, sorry. So plain OpenCV is basically a dead end? What should I be using instead?
Correct - for this HAT, skip plain cv2.VideoCapture(0). Instead, use Arducam’s picamera2 OpenCV capture example:
The main thing to understand is that the Camarray HAT is treated as a single IMX219 camera module, so you don’t need any extra libraries/imports beyond picamera2 (and OpenCV for displaying frames).
A few connection notes:
Connect at least one camera to the RX2 or RX3 port on the HAT.
On a Raspberry Pi 5, to use a second Camarray HAT you’d add dtoverlay=imx219,cam0 in the config file. But on your Pi 4, you’re hardware-limited to one HAT because of the single CSI port.
Give that example a try and report back with any errors.
Thanks, I followed those steps and used the CaptureOpencvExample.py script from that link, but I’m still hitting an error when accessing the cameras from Python. I’ve attached screenshots of the error:
Thanks for the screenshots. A few things to check, since the error happens when you run the Python script:
Confirm at least one camera is connected to RX2 or RX3 on the HAT (this matters - not just any port).
Make sure picamera2 is installed and up to date on the 64-bit OS.
Run the example exactly as provided before modifying anything. It should enumerate the Camarray HAT as a single IMX219 device.
If the error points to camera detection/opening the device, reseat the CSI ribbon cable and the camera flex cables first - that’s the most common cause.
Can you paste the actual text of the Python error from those screenshots? That will tell us whether it’s a detection issue, a missing package, or something inside the script.
Glad it’s working! To summarize for anyone else with the same kit:
Don’t use plain cv2.VideoCapture(0) - use the picamera2 OpenCV capture example instead.
Treat the Camarray HAT as a single IMX219 camera module (no extra libraries needed), and connect at least one camera to RX2 or RX3.
The Raspberry Pi 4 only has one CSI port, so it’s limited to a single Camarray HAT. For a second HAT you’d need a Raspberry Pi 5 and add dtoverlay=imx219,cam0 to the config.