Picamera not working as expected

raspberrypizero
#1

Hi,

I have been trying to get the rpi camera to work but it seems there’s something wrong with the io.balena.features.kernel-modules label. These are my Dockerfile and docker-compose file:

docker-compose.yml

version: '2.1'

services:
  picture:
build: .
restart: always
privileged: true
labels:
  io.balena.features.kernel-modules: '1'
  io.balena.features.dbus: '1'

Dockerfile

FROM balenalib/raspberry-pi-alpine-python:3.7-3.8

RUN pip install -U pip \
    && READTHEDOCS=True pip install --no-cache-dir picamera

WORKDIR /src
COPY . .
CMD modprobe v4l2_common && python test.py

My test.py file just imports the picamera module.

This will always result in the following error:

19.03.19 23:11:12 (+0100)  test-image  Traceback (most recent call last):
19.03.19 23:11:12 (+0100)  test-image    File "sample.py", line 2, in <module>
19.03.19 23:11:12 (+0100)  test-image      import picamera
19.03.19 23:11:12 (+0100)  test-image    File "/usr/local/lib/python2.7/site-packages/picamera/__init__.py", line 72, in <module>
19.03.19 23:11:12 (+0100)  test-image      from picamera.exc import (
19.03.19 23:11:12 (+0100)  test-image    File "/usr/local/lib/python2.7/site-packages/picamera/exc.py", line 41, in <module>
19.03.19 23:11:12 (+0100)  test-image      import picamera.mmal as mmal
19.03.19 23:11:12 (+0100)  test-image    File "/usr/local/lib/python2.7/site-packages/picamera/mmal.py", line 47, in <module>
19.03.19 23:11:12 (+0100)  test-image      from .bcm_host import VCOS_UNSIGNED
19.03.19 23:11:12 (+0100)  test-image    File "/usr/local/lib/python2.7/site-packages/picamera/bcm_host.py", line 47, in <module>
19.03.19 23:11:12 (+0100)  test-image      _lib = ct.CDLL('libbcm_host.so')
19.03.19 23:11:12 (+0100)  test-image    File "/usr/local/lib/python2.7/ctypes/__init__.py", line 366, in __init__
19.03.19 23:11:12 (+0100)  test-image      self._handle = _dlopen(self._name, mode)
19.03.19 23:11:12 (+0100)  test-image  OSError: libbcm_host.so: cannot open shared object file: No such file or directory

I have tried the example provided on https://github.com/balena-io-projects/balena-rpi-python-picamera and I get the exact same result.

Can anyone look into this? I’m trying this on both a RPi Zero W and a RPi3-B

Thank you.

#4

As a follow up on my previous post, the workaround to get this to work is to use the debian base image instead of the alpine and install libraspberrypi-bin package. Without it seems the shared libraries are not present.

Can someone double check that this example is actually working? https://github.com/balena-io-projects/balena-rpi-python-picamera

thanks,
nelson