Closed Exper1mental closed 4 months ago
Which Version of pi camera is that? V3 or the Araducam? Could be a memory allocation issue but I am not sure. This system has not been tested on the Araducam (I don't have one)
Hmm interesting... I'm using a Pi camera module 3 wide though. ¯\_(ツ)_/¯
what happens when you type libcamera-hello can you paste the output (do that before going into the venv)
Also Raspberry Pi OS 64bit. --- lite or desktop ... trying to narrow down the issue
Running libcamera-hello
out of venv displayed the popup preview window as expected with a live view from the camera and gives the following output:
libcamera-hello
[6:52:16.986787243] [7603] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[6:52:17.033919132] [7606] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[6:52:17.036115052] [7606] INFO RPI vc4.cpp:447 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media1 and ISP device /dev/media2
[6:52:17.036193327] [7606] INFO RPI pipeline_base.cpp:1144 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Made X/EGL preview window
Mode selection for 2304:1296:12:P
SRGGB10_CSI2P,1536x864/0 - Score: 3400
SRGGB10_CSI2P,2304x1296/0 - Score: 1000
SRGGB10_CSI2P,4608x2592/0 - Score: 1900
Stream configuration adjusted
[6:52:17.510516614] [7603] INFO Camera camera.cpp:1183 configuring streams: (0) 2304x1296-YUV420 (1) 2304x1296-SBGGR10_CSI2P
[6:52:17.512707497] [7606] INFO RPI vc4.cpp:611 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
I'm using Raspberry Pi OS with Desktop 64-bit (Bookworm / Debian 12)
I've submitted an issue on the Picamera2 Github repo. Seems like this may be a bug in the library? https://github.com/raspberrypi/picamera2/issues/972
Going to abuse this to take the install notes
This what I did to get this working on 32bit Lite Pi OS
This was working for me... I am waiting on a SD card for 64bit
I had forgotten you use v0.0.4 and yeah its still functioning so I am at a loss... I did have one issue with the 64bit version but when I reseated the cable it was fine.
Do you want to clean install the OS and try the above steps
I initially was able to get this working by setting buffer_count=5
for picam2.create_video_configuration
(the default is 6
).
Upon further investigation, Visual Studio Code uses a small (~30 MB) amount of CMA memory and this was sufficient to cause the error. Closing VSC and running from Terminal allowed me to push the buffer count back to 6
Closing since this isn't a bug.
grep Cma /proc/meminfo
tells how much CMA memory is currently available and in-use.
dtoverlay -h vc4-fkms-v3d
tells you what values your Pi will accept for defining CMA memory allocation.
Per page 58 (section 8.3) the Picamera2 manual, you can then edit the /boot/firmware/config.txt
(previously /boot/config.txt
) file to set CMA memory.
Just in case it helps ...
Raspian bookworm 32bit lite, Raspi 3B, fresh install. CMA memory config changes did not help, but I raised it to 320 and confirmed the settings are in use. What helped at the end: adding buffer_count=4 (!) to the statement creating the video config.
I'm having a simillar issue. I guess mine is an Arducam (v1.3? It's ov5647
at least), can't tell exactly (info command welcomed).
I'm running DietPi 9.4.2 The error is the following:
root@DietPi:~/picamera2-WebUI-Lite# python3 app.py
[0:12:10.852686000] [2347] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+120-eb00c13d
[0:12:11.081730000] [2371] WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:12:11.103053000] [2371] INFO RPI vc4.cpp:446 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media2 and ISP device /dev/media0
[0:12:11.104807000] [2371] INFO RPI pipeline_base.cpp:1102 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[0:12:11.131601000] [2347] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+120-eb00c13d
[0:12:11.329701000] [2374] WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:12:11.350595000] [2374] INFO RPI vc4.cpp:446 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media2 and ISP device /dev/media0
[0:12:11.352322000] [2374] INFO RPI pipeline_base.cpp:1102 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Camera Config:
{'controls': {'LensPosition': 1.0, 'ExposureValue': 0.0, 'ExposureTime': 220417486, 'AwbMode': 0, 'AfSpeed': 0, 'AfRange': 0, 'AeMeteringMode': 0, 'AeFlickerPeriod': 1000000, 'AeFlickerMode': 0, 'AeExposureMode': 0, 'AeEnable': True, 'AwbEnable': True, 'AeConstraintMode': 0, 'Brightness': 0.0, 'Contrast': 1.0, 'Saturation': 1.0, 'Sharpness': 1.0, 'AfMode': 0, 'ScalerCrop': [0, 0, 4608, 2592]}, 'rotation': {'hflip': 0, 'vflip': 0}, 'sensor-mode': 0, 'capture-settings': {'Resize': False, 'makeRaw': False, 'Resolution': 0, 'available-resolutions': [[4608, 2592], [2304, 1296], [1920, 1080], [1280, 720], [640, 360]]}}
Camera Settings:
{'Resize': False, 'makeRaw': False, 'Resolution': 0, 'available-resolutions': [[4608, 2592], [2304, 1296], [1920, 1080], [1280, 720], [640, 360]]}
Camera Set Resolution:
[4608, 2592]
[0:12:11.439154000] [2347] INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-XBGR8888 (1) 640x480-SGBRG10_CSI2P
[0:12:11.442684000] [2374] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA
[0:12:11.518807000] [2347] INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-XBGR8888 (1) 1296x972-SGBRG10_CSI2P
[0:12:11.523524000] [2374] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
[0:12:11.621510000] [2347] INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-XBGR8888 (1) 1920x1080-SGBRG10_CSI2P
[0:12:11.624426000] [2374] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected unicam format: 1920x1080-pGAA
[0:12:11.809884000] [2347] INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-XBGR8888 (1) 2592x1944-SGBRG10_CSI2P
[0:12:11.822447000] [2374] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAA
Video Config:
{'use_case': 'video', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'Rec709'>, 'buffer_count': 6, 'queue': True, 'main': {'format': 'XBGR8888', 'size': (4608, 2592)}, 'lores': None, 'raw': {'format': 'SGBRG10_CSI2P', 'size': (4608, 2592)}, 'controls': {'NoiseReductionMode': <NoiseReductionModeEnum.Fast: 1>, 'FrameDurationLimits': (33333, 33333)}, 'sensor': {'output_size': (640, 480), 'bit_depth': 10}, 'display': 'main', 'encode': 'main'}
Picamera2 Camera Properties:
{'Model': 'ov5647', 'UnitCellSize': (1400, 1400), 'ColorFilterArrangement': 2, 'Location': 2, 'Rotation': 0, 'PixelArraySize': (2592, 1944), 'PixelArrayActiveAreas': [(16, 6, 2592, 1944)], 'ScalerCropMaximum': (0, 0, 2592, 1944), 'SystemDevices': (20749, 20737, 20738, 20739), 'SensorSensitivity': 1.0}
INFO:picamera2.picamera2:Camera configuration has been adjusted!
[0:12:12.163953000] [2347] INFO Camera camera.cpp:1183 configuring streams: (0) 4608x2592-XBGR8888 (1) 640x480-SGBRG10_CSI2P
[0:12:12.166702000] [2374] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA
INFO:picamera2.picamera2:Configuration successful!
Traceback (most recent call last):
File "/root/picamera2-WebUI-Lite/app.py", line 508, in <module>
start_camera_stream()
File "/root/picamera2-WebUI-Lite/app.py", line 304, in start_camera_stream
picam2.configure(video_config)
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1114, in configure
self.configure_(camera_config)
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1097, in configure_
self.allocator.allocate(libcamera_config, camera_config.get("use_case"))
File "/usr/lib/python3/dist-packages/picamera2/allocators/dmaallocator.py", line 43, in allocate
fd = self.dmaHeap.alloc(f"picamera2-{i}", stream_config.frame_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/picamera2/dma_heap.py", line 98, in alloc
ret = fcntl.ioctl(self.__dmaHeapHandle.get(), DMA_HEAP_IOCTL_ALLOC, alloc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 12] Cannot allocate memory
INFO:picamera2.picamera2:Camera closed successfully.
Also, when try running libcamera-hello
:
root@DietPi:~/picamera2-WebUI-Lite# libcamera-hello
[0:15:15.074101000] [2590] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+120-eb00c13d
[0:15:15.436101000] [2600] WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:15:15.457388000] [2600] INFO RPI vc4.cpp:446 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media2 and ISP device /dev/media0
[0:15:15.459161000] [2600] INFO RPI pipeline_base.cpp:1102 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Preview window unavailable
Mode selection for 1296:972:12:P
SGBRG10_CSI2P,640x480/0 - Score: 3296
SGBRG10_CSI2P,1296x972/0 - Score: 1000
SGBRG10_CSI2P,1920x1080/0 - Score: 1349.67
SGBRG10_CSI2P,2592x1944/0 - Score: 1567
Stream configuration adjusted
[0:15:15.597634000] [2590] INFO Camera camera.cpp:1183 configuring streams: (0) 1296x972-YUV420 (1) 1296x972-SGBRG10_CSI2P
[0:15:15.600346000] [2600] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
#0 (0.00 fps) exp 33222.00 ag 8.00 dg 1.00
#1 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#2 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#3 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#4 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#5 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#6 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#7 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#8 (30.03 fps) exp 33222.00 ag 8.00 dg 1.00
#9 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#10 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#11 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#12 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#13 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#14 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#15 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#16 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#17 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#18 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#19 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#20 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#21 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#22 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#23 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#24 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#25 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#26 (30.03 fps) exp 33222.00 ag 8.00 dg 1.00
#27 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#28 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#29 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#30 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#31 (30.03 fps) exp 33222.00 ag 8.00 dg 1.00
#32 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#33 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#34 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#35 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#36 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#37 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#38 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#39 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#40 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#41 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#42 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#43 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#44 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#45 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#46 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#47 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#48 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#49 (30.03 fps) exp 33222.00 ag 8.00 dg 1.00
#50 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#51 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#52 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#53 (30.03 fps) exp 33222.00 ag 8.00 dg 1.00
#54 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#55 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#56 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#57 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#58 (30.00 fps) exp 33222.00 ag 8.00 dg 1.00
#59 (30.04 fps) exp 33222.00 ag 8.00 dg 1.00
#60 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#61 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#62 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#63 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00
#64 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#65 (30.00 fps) exp 33222.00 ag 7.94 dg 1.01
#66 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#67 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#68 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#69 (30.03 fps) exp 33222.00 ag 7.94 dg 1.01
#70 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#71 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#72 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#73 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#74 (30.00 fps) exp 33222.00 ag 7.94 dg 1.01
#75 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#76 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#77 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#78 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#79 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#80 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#81 (30.02 fps) exp 33222.00 ag 7.94 dg 1.01
#82 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#83 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#84 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#85 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#86 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#87 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#88 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#89 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#90 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#91 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#92 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#93 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#94 (30.02 fps) exp 33222.00 ag 7.88 dg 1.02
#95 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
^C
I'm running this using python3, didn't digged too much in the repo code to tell if that's a difference, but as I found this issue opened, discarded that to be the reason. Hope the info helps.
Describe the bug When I run
python app.py
I am given the error:RuntimeError: Failed to start camera: Cannot allocate memory
.Here is the full output:
To Reproduce Steps to reproduce the behavior:
python -m venv --system-site-package venv
(to access system packages like picamera2)python app.py
(I might've installed flask first in the venv; can't remember)Expected behavior The script start up without error.
Desktop (please complete the following information):
Additional context For reference, here are the packages installed / accessible through the venv:
What should I do to fix this?
Thanks!