picamera2: [BUG] Opening camera fails on Stellarmate OS
Describe the bug
Opening the HQ camera on Stellarmate raises errors RuntimeError: Non-owning holder (loaded_as_shared_ptr).
and RuntimeError: Camera __init__ sequence did not complete.
.
To Reproduce
#!/usr/bin/env python3
from picamera2 import Picamera2
# get list of available cameras:
cameras = Picamera2.global_camera_info()
if len(cameras) > 0:
print(f'Opening camera 0: {cameras[0]}')
picam2 = Picamera2(0)
print('Success.')
else:
print('WARNING: No camera found!')
print('Finished.')
Expected behaviour The test script should finish without errors.
Console Output, Screenshots
stellarmate@stellarmate:~/Projects/indi_pylibcamera $ ./test.sh
[1:01:18.484283460] [10540] INFO Camera camera_manager.cpp:299 libcamera v0.0.1
[1:01:18.550090496] [10541] INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media4 and ISP device /dev/media1
Opening camera 0: {'Model': 'imx477', 'Location': 2, 'Rotation': 180, 'Id': '/base/soc/i2c0mux/i2c@1/imx477@1a'}
[1:01:18.553176786] [10540] INFO Camera camera_manager.cpp:299 libcamera v0.0.1
[1:01:18.623775182] [10545] INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media4 and ISP device /dev/media1
Camera __init__ sequence did not complete.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 237, in __init__
self._open_camera()
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 447, in _open_camera
if not self._initialize_camera():
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 431, in _initialize_camera
self.sensor_format = str(self.camera.generate_configuration([RAW]).at(0).pixel_format)
RuntimeError: Non-owning holder (loaded_as_shared_ptr).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/stellarmate/Projects/indi_pylibcamera/./test.sh", line 10, in <module>
picam2 = Picamera2(0)
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 244, in __init__
raise RuntimeError("Camera __init__ sequence did not complete.")
RuntimeError: Camera __init__ sequence did not complete.
Hardware :
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
uname -a
Linux stellarmate 5.15.76-v8+ #1597 SMP PREEMPT Fri Nov 4 12:16:41 GMT 2022 aarch64 GNU/Linux
apt list --installed | grep libcamera
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libcamera-apps/unknown,now 1.0-stable~202211161401 arm64 [installed]
libcamera-dev/unknown,now 1.0-stable~202211161314 arm64 [installed]
libcamera-tools/unknown,now 1.0-stable~202211161314 arm64 [installed]
libcamera0/unknown,now 1.0-stable~202211161314 arm64 [installed,automatic]
python3-libcamera/unknown,now 1.0-stable~202211161314 arm64 [installed,automatic]
apt list --installed | grep picamera
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
python3-picamera2/stable,stable,now 0.3.7-1 all [installed]
Additional context Libcamera apps work as expected:
libcamera-hello --list-cameras
Available cameras
-----------------
0 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a)
Modes: 'SRGGB10_CSI2P' : 1332x990 [120.05 fps - (696, 528)/2664x1980 crop]
'SRGGB12_CSI2P' : 2028x1080 [50.03 fps - (0, 440)/4056x2160 crop]
2028x1520 [40.01 fps - (0, 0)/4056x3040 crop]
4056x3040 [10.00 fps - (0, 0)/4056x3040 crop]
libcamera-still -r -o test.jpg
Made X/EGL preview window
[0:06:15.342289179] [2106] INFO Camera camera_manager.cpp:299 libcamera v0.0.1
[0:06:15.436879300] [2108] INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media3 and ISP device /dev/media0
[0:06:15.439898121] [2106] INFO Camera camera.cpp:1026 configuring streams: (0) 2028x1520-YUV420
[0:06:15.442013971] [2108] INFO RPI raspberrypi.cpp:766 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 2028x1520-SBGGR12_1X12 - Selected unicam format: 2028x1520-pBCC
[0:06:21.110365388] [2106] INFO Camera camera.cpp:1026 configuring streams: (0) 4056x3040-YUV420 (1) 4056x3040-SBGGR12_CSI2P
[0:06:21.112770963] [2108] INFO RPI raspberrypi.cpp:766 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 4056x3040-SBGGR12_1X12 - Selected unicam format: 4056x3040-pBCC
Still capture image received
Bayer format is BGGR-12
This issue is related to https://github.com/scriptorron/indi_pylibcamera/issues/1.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16
Hi everyone, and thanks for joining the discussion!
Indeed there are some problems in this area. In particular, the current top-of-tree libcamera breaks some functionality on the Raspberry Pi, though I have submitted patches to resolve this. But it does highlight a general problem in the use of bleeding edge code and APIs and ABIs that are changing, so we’ll have to think how best to deal with that.
We are trying to get some better testing in place for the Raspberry Pi on top-of-tree libcamera (thanks to Kieran for that), so we should at least see some improvement in the future.