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

Camera board • Arducam Multi Camera Adapter with Picamera2

$
0
0
Hi,
Recently, I faced a problem below:
Set up
  • RaspberryPi 4B 8 GB
  • Bullseye OS 64 bi, kernel version:6.1.21
I'm using dtoverlay=camera-mux-4port,cam0-ov5647,cam1-ov5647 in the config and libcamera-hello -t 0 --camera 0 and libcamera-hello -t 0 --camera 1 both successfully run in the terminal and produce a preview feed from each of the respective cameras, so I know the cameras are properly connected and functional.

print(Picamera2.global_camera_info()) produces
[{'Model': 'ov5647', 'Location': 2, 'Rotation': 0, 'Id': '/base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36'}, {'Model': 'ov5647', 'Location': 2, 'Rotation': 0, 'Id': '/base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36'}]

The issue comes in using Picamera2 to switch between these cameras. Calling stop() on one camera and then calling start() on the other results in a device busy error. If I call close() then I can successfully start the other camera, but close() completely deallocates the camera object and closing and re-creating camera objects is computationally expensive and slow.
Below is a sample code that shows the problem.

Code:

from picamera2 import Picamera2import timecam0 = Picamera2(0)cam1 = Picamera2(1)cam0.start()cam0.capture_file("cam0.jpg")cam0.stop()  #code succeeds if this is cam0.close()time.sleep(5)cam1.start()cam1.capture_file("cam1.jpg")cam1.stop()
ERROR V4L2 v4l2_videodevice.cpp:1047 /dev/video0[26:cap]: Unable to set format: Device or resource busy

Code:

Traceback (most recent call last):  File "/home/me/tests/test.py", line 15, in <module>    cam1.start()  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1049, in start    self.configure(config)  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1004, in configure    self.configure_(camera_config)  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 943, in configure_    if self.camera.configure(libcamera_config):RuntimeError: Failed to configure camera: Device or resource busy
Is this Multiplexer not compatible with Picamera2? Hopefully, you shed light on this problem.
Thank you in advance :D
BTW, ask if you need more information from me.

Statistics: Posted by DaPiLad — Fri Apr 12, 2024 2:43 am — Replies 0 — Views 39



Viewing all articles
Browse latest Browse all 4916

Trending Articles