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

Camera board • Memory issues with picamera2

$
0
0
I'm running a IMX519 16mp camera on a pi 4/4gb. If I try to set up a config greater than 1920x1080, I get a memory error:

Code:

Traceback (most recent call last):  File "/home/pi/spincam/cam.py", line 181, in do_POST    photo.clickShutter()  File "/home/pi/spincam/cam.py", line 168, in clickShutter    self.picam2.switch_mode_and_capture_file(self.still_config, filename)  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1466, in switch_mode_and_capture_file    return self.dispatch_functions(functions, wait, signal_function, immediate=True)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1362, in dispatch_functions    return job.get_result(timeout=timeout) if wait else job           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/job.py", line 79, in get_result    return self._future.result(timeout=timeout)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result    return self.__get_result()           ^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result    raise self._exception  File "/usr/lib/python3/dist-packages/picamera2/job.py", line 48, in execute    done, result = self._functions[0]()                   ^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1429, in switch_mode_    self.configure_(camera_config)  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1109, 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
In the docs for the camera, it suggests adding "CMA 400M" to the end of cmdline.txt to increase the size of the CMA/DMA heap. However, with this in place, I get (for ANY resolution):

Statistics: Posted by blindahl42 — Mon Feb 24, 2025 5:49 pm — Replies 2 — Views 44



Viewing all articles
Browse latest Browse all 4481

Trending Articles