Two camera streams on Pi5 conflict

My hardware is Pi5/8GB/active cooler and two OV5647 cameras.
OS is Bookworm.

To get set up, I ran the following:

sudo apt-get install libopencv-dev
sudo apt-get install python3-opencv

To test this install, I checked in Thonny’s interpreter:

import cv2
print(cv2._ version _)

(As and aside, I was expecting the latest, version 4.9.0, but maybe this command hearkens back in time.)

Then to check the camera connections:

libcamera-hello --list-cameras

and I get:

Available cameras

0 : ov5647 [2592x1944 10-bit GBRG] (/base/axi/pcie@120000/rp1/i2c@88000/ov5647@36)
Modes: ‘SGBRG10_CSI2P’ : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]
1296x972 [43.25 fps - (0, 0)/2592x1944 crop]
1920x1080 [30.62 fps - (348, 434)/1928x1080 crop]
2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

1 : ov5647 [2592x1944 10-bit GBRG] (/base/axi/pcie@120000/rp1/i2c@80000/ov5647@36)
Modes: ‘SGBRG10_CSI2P’ : 640x480 [30.00 fps - (0, 0)/0x0 crop]
1296x972 [30.00 fps - (0, 0)/0x0 crop]
1920x1080 [30.00 fps - (0, 0)/0x0 crop]
2592x1944 [30.00 fps - (0, 0)/0x0 crop]

These two cameras implement the left and the right eyes on a head. To get a video stream from both eyes, I run the following in two separate terminals:


libcamera-hello --camera 0 -t 0 --vf

and right:

libcamera-hello --camera 1 -t 0 --vf

with the vertical flip flag because the cable routing forced me to install the cameras upside down.

When only one camera is active, there is no problem. If I start streaming from the left eye only, I get a pop-up window showing what it sees in real time, with the correct orientation, good colors, no problem. Same for the right eye.
The problem manifests itself only after the second stream is initiated from the other eye. What happens then, is that the first stream gets corrupted. Specifically, the orientation flips vertically as if I had no --vf flag. In addition, its hue gets messed up and the overall color content turns very blue or very green or purple or some color combination. (The gray scale and the frames per second remain fine, although sometimes the pictures get really grainy.) Meanwhile the second stream looks okay, as if it was the only one running.

It seems the functions handling the second stream are affecting the previous one. Not corrupting it completely but enough to mess things up. I haven’t written an application for the visuals yet, I’m just trying to use these “Hello World” samples. Maybe from python code everything would work?

Also, I tried to use different libraries for the two terminals, thinking that perhaps this would keep the buffers more independent. In one terminal, I run the test with


and in the other terminal, with


with the same flags, but this does not help either.

Please assist.

Sorry, not an OpenCV problem. Find the forum for Raspberry Pi. They are the best place to ask.

As for only getting v4.6, that’s a matter of debian/ubuntu preferring “aged” code or the package maintainer not keeping up with OpenCV releases. Debian-maintained packages are frequently not maintained by the actual developers of a library. The official releases of OpenCV can be found on the github (C++, Java, …) or on PyPI (opencv-python and siblings).