Why does stopping camera 1 and then starting camera 0 not work?
Picamera2 is supposed to be libcamera based and `libcamera-hello -t 0 --camera 0` followed by `libcamera-hello -t 1` works correctly.
To switch the mux board between cameras, it needs to change 3 GPIO pins (pins 7, 11, and 12 or GPIO 4, GPIO 17, and GPIO 18) and updates the I2C at chip address 0x70 and data address 0x00 to be 0x04, 0x05, 0x06, or 0x07.
Libcamera handles this, and Picamera2 is built on top of Libcamera.
The dtoverlay for the camera-mux-4port is now native on the raspberry pi OS. (I'm using Bullseye 64 full on a pi4b).
Calling cam0.close() allows for cam1.start() to be called, but that's because close() entirely deallocates cam0. You have to redeclare a new cam0 = Picamera2(0) to use it again, and that closing and recreating is slow.
I've been trying to read through the picamera2 docs and code but I don't understand why the start() and close() functions can't utilize the dtoverlay to control the necessary outputs to swap between the cameras on the mux board / as subdev nodes on the dev/video0.
Code:Error:
Picamera2 is supposed to be libcamera based and `libcamera-hello -t 0 --camera 0` followed by `libcamera-hello -t 1` works correctly.
To switch the mux board between cameras, it needs to change 3 GPIO pins (pins 7, 11, and 12 or GPIO 4, GPIO 17, and GPIO 18) and updates the I2C at chip address 0x70 and data address 0x00 to be 0x04, 0x05, 0x06, or 0x07.
Libcamera handles this, and Picamera2 is built on top of Libcamera.
The dtoverlay for the camera-mux-4port is now native on the raspberry pi OS. (I'm using Bullseye 64 full on a pi4b).
Calling cam0.close() allows for cam1.start() to be called, but that's because close() entirely deallocates cam0. You have to redeclare a new cam0 = Picamera2(0) to use it again, and that closing and recreating is slow.
I've been trying to read through the picamera2 docs and code but I don't understand why the start() and close() functions can't utilize the dtoverlay to control the necessary outputs to swap between the cameras on the mux board / as subdev nodes on the dev/video0.
Code:
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()
Code:
ERROR V4L2 v4l2_videodevice.cpp:1047 /dev/video0[26:cap]: Unable to set format: Device or resource busyTraceback (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
Statistics: Posted by cjb69192 — Fri Apr 12, 2024 1:32 am