Hi everyone, hoping someone can point me in the right direction. I’ve got an Arducam camera that refuses to connect in my Python/OpenCV project. The weird part is the exact same program works fine with other Raspberry Pi cameras. The video loop never even starts because in ret, frame = self.cap.read() the ret value never comes back as True. I’ve never managed to get this Arducam working with the project at all.
Welcome to the forum! A few questions to help narrow this down. What Raspberry Pi model are you on, and which exact Arducam module is it? Also what does your software stack look like (OS, Python, OpenCV versions)? And have you been able to test the camera outside of OpenCV, for example with the libcamera command?
Thanks for the reply. It’s a Raspberry Pi 4B 4GB, and the camera is the Arducam 12MP IMX708 HDR 120° wide angle camera module with M12 lens. Software side it’s Python with OpenCV. The funny thing is the camera does work when I use the libcamera command, so it’s not completely dead - it’s just OpenCV that won’t cooperate.
Good info. Can you paste the relevant code around the capture loop and anything in your boot config related to the camera overlay? Also, are there any error messages or logs printed when the read fails?
Sure. The failing line is ret, frame = self.cap.read() - it just never returns a True for ret. In config.txt I have dtoverlay=imx477. I didn’t grab any logs from the failure itself, sorry. I’ve already tried a few things: set the imx477 overlay, and I wrote up the whole saga over on Stack Exchange here: https://raspberrypi.stackexchange.com/questions/144874/arducam-refusing-to-connect-but-other-camera-works-with-opencv. I also attached a bug report earlier. Honestly at this point I’m ready to just switch libraries - do you have any picamera2 demo code I could start from?
Since the camera works with the libcamera command, that confirms the hardware itself is normal. The problem is specific to your OpenCV-based project. Your video loop depends on ret being returned as True from self.cap.read(), and OpenCV isn’t getting a valid frame from this camera, so the loop never starts. One thing to note: for this camera we only provide simple demo Python code using the picamera2 library, so I can’t offer direct advice on the OpenCV side.
That makes sense, and switching libraries is honestly fine with me. How do I generate that Arducam bug report you mentioned? And do you have a link to that picamera2 demo code?
To generate the Arducam camera bug report, do the following:
- Reboot your device.
- Download the bug report tool:
wget -O arducam-camera-bug-report https://github.com/ketai-dhr/arducam-camera-bug-report/releases/download/tools/arducam-camera-bug-report - Make it executable:
chmod +x ./arducam-camera-bug-report - Run it:
./arducam-camera-bug-report
This will produce an arducam-bug-report.txt file in the current directory. Please send that file to me in a private message so we can analyze it further.
For picamera2, here’s the simple preview demo to get you started: picamera2/examples/preview.py at main · raspberrypi/picamera2 · GitHub
There are more example scripts in the raspberrypi/picamera2 repository if you want to look around.
Perfect, thanks. I’ve run the bug report tool and sent the file over in a private message. The preview example looks like exactly what I need - I’ll go ahead and change libraries.
Quick summary of where we’ve landed: your OpenCV program works with other RPi cameras but not with the Arducam 12MP IMX708 HDR 120° wide angle camera module on the Pi 4B 4GB, and you’d already tried dtoverlay=imx477 without success. Since the camera responds correctly to libcamera, the hardware is fine - the issue is specific to the OpenCV capture path. Our demo code is picamera2-based only, so the current workaround is to use the picamera2 preview example as a starting point and port your capture loop over. The camera itself is documented here if you need the spec: https://www.arducam.com/product/presalearducam-12mp-imx708-hdr-120-wide-angle-camera-module-with-m12-lens-for-raspberry-pi/
Let us know how it goes once you’ve made the switch.