Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4397

Camera board • Issue Using Two Cameras Simultaneously with libcamera on Raspberry Pi 5

$
0
0
Hello everyone,

I’m encountering a problem when trying to use two cameras simultaneously on a Raspberry Pi 5 with libcamera. Here’s the setup and the issue:

Setup
Raspberry Pi 5
Two cameras connected to two different ports (0 and 1)
libcamera library used for capturing images
A software application that allows me to choose the camera (port 0 or port 1) and take a picture through a command-line interface.

Behavior
When I run a single instance of the application and select a specific camera, everything works perfectly: I can capture images from either camera 0 or camera 1 as expected.

However, the problem arises when I try to run two instances of the application simultaneously, with each targeting a different camera. The following issues occur:

Crash: Sometimes the second camera process crash unexpectedly.
Wrong camera ysed: In other cases, both processes end up using camera 0, even though one process was specifically configured to use camera 1.

Details
By design, there’s only one libcamera context per application instance.
I’ve made sure that each process is using a different camera ID (based on CameraManager::get() and the respective camera IDs for ports 0 and 1).
It seems there’s some conflict or mismanagement when two processes try to access the cameras at the same time.
What I’ve Tried
Ensured that each process correctly initializes its own libcamera context and selects the desired camera.
Verified that the camera IDs are distinct and correctly correspond to the two physical cameras.
Tested the application in isolation (one process at a time), and it works flawlessly.

Questions
Is there a known limitation in libcamera or the Raspberry Pi hardware that prevents two independent processes from accessing separate cameras simultaneously?
Are there specific settings or configurations I should be using to make this work?
Could this be an issue with the underlying driver or hardware abstraction layer?

Additional Notes
I’m using the latest version of libcamera available on Raspberry Pi OS.
The cameras are one official Raspberry Pi camera V3 and one Arducam 64mp if relevant.


Any guidance or suggestions to resolve this issue would be greatly appreciated! Thank you in advance for your help.

Statistics: Posted by fescobar — Thu Dec 12, 2024 1:43 pm — Replies 0 — Views 11



Viewing all articles
Browse latest Browse all 4397

Trending Articles