IMX477 stereo camera from Python/C++ program (Raspberry Pi 4)

Hardware: Raspberri pi 4 Model B
Operation system: Raspberry Pi OS (64 bit) Debian Bullseye RPi Desktop
Camera: Two 12.3MP IMX477 Camera Modules with CS Lens and Camarray Stereo Camera HAT

I would like to use the two camera from a python or c++ program with opencv. The libcamera-still can open the cameras from terminal but I cannot open them from program. I enabled the camera, followed the tutorial and wrote the needed parameters in the /boot/config.txt file. Still I can’t use and open the camera from program. Firstly the error was somthing like this:
error: …\src\opencv\modules\highgui\src\window.cpp:261: error: (-215)
size.width>0 && size.height>0

We have a Raspberry Pi 3 Model B with a simple Raspberry Pi HQ Camera (12MP) with the same IMX477 Sony chip and that works perfectly on a Buster Debian operation system.

I read something about the firmware that it changed in case of the stereo camera compared to the single HQ camera. I am not sure what is the problem here.

I also wanted to try the Arducam driver but as I realised and read on the arducam forum it makes the libcamera crash. The only problem is that the arducam driver messed up the libcamera and it’s not working but neither the arducam.

hi, @szzekany

How did your program get the image?

You need to use libcamera in your program to get the image and finally display it with opencv.

It is recommended to use the picamera2 python library officially produced by Raspberry Pi, which is the python packaging library of libcamera. It allows you to access the camera using libcamera in python.

Dear @yang

Thank you very much for the advice. I’ll try to solve it like this.

The original idea is to make a black background photo. I would like to do it with decreasing the shutter speed the minimal, set the ISO and aparture at the proper value and lighten the object with a very intense led. I want to do it because I would like to create a segmentation neural network and I beleive it can be a good solution for that. We build a strobe around the camera and would like to time the led lights at the proper time to create a black background photo.

Could you please help me with this issue? Can we get the strobe signal some way to syncronize the strobing to the acttual time when the photo is taken? We have two capacitor and would like to discharge it the moment we take the photo. The leds become really hot in a little amount of time so we cannot make light for a long time, this is why we need to perfectly syncroneze the lights and the moment we take the photo.

hi, @szzekany

Sorry, I don’t know much about this one. Can’t help you.