-
Hi, I tried the following setup:
Dockerfile: FROM dtcooper/raspberrypi-os:bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y \
python3 \
python3-picamera2 --no-install-recommends
RUN ln -s /usr/bin/python3 /usr/bin/python
WORKDIR /app
COPY . .
CMD ["python", "code/camera.py"] docker-compose.yml: name: picamera2-test
services:
picamera2-test:
build: .
stdin_open: true
tty: true
container_name: picamera2-test
volumes:
- ./code:/code
- /run/udev/:/run/udev:ro
devices:
- /dev/video0:/dev/video0
privileged: true ./code/camera.py: from picamera2 import Picamera2
picam2 = Picamera2(0)
picam2.start_and_capture_file("/code/test.jpg", show_preview=False)
print("Captured /code/test.jpg") The error log is:
Choosing camera 1 with the lower resolution works fine:
I have also tried the solution #954 from @hyzhak replacing his streaming server with my Python code. But this gives the same result. I also took notice from ch. 8.3 of the picamera2-manual but I am currently not able to translate this Docker directives. Any help would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Have you read this: https://docs.docker.com/engine/containers/resource_constraints/ ? |
Beta Was this translation helpful? Give feedback.
@davidplowman, thanks for clarification.
I tried to analyze this a little bit more.
Looking at the available cma on my Pi 5,
cat /proc/meminfo
shows:Since, according to the picamera2-manual ch. 8.3, the 12MP Model 3 image requires 48 MB, this will probably be the bottleneck.
I increased cma by replacing
with
in
/boot/firmware/config.txt
Now, after reboot, I have:
Now, the
Cannot allocate memory
error is gone when running the docker container with the Model 3 camera and a 12MP image is created.Doesn't this indicate tha…