Unable to run Balena-Cam on Raspberry Pi 4

I hope this message finds you well. I’m currently working on a project that involves classifying socks using a Raspberry Pi, Edge Impulse, and Balena. I’ve been following the instructions provided in this blog post: How to classify socks using a Raspberry Pi, Edge Impulse, and balena.
So far, I’ve managed to set up the project as per the instructions, and the edge-impulse microservice is working perfectly on my Raspberry Pi. However, I encountered an issue with the balena-cam microservice during the release phase. It seems that it’s no longer supported for the Raspberry Pi 4’s 64-bit OS, and piwheels no longer supports the aarch64 architecture.

After some research and experimentation, I made some edits to the Dockerfile, and I was able to successfully build it. However, when I launch the application, it hangs and doesn’t function as expected.

I would be extremely grateful if someone could kindly assist me in overcoming these issues so that I can run this project successfully for my Uni project. Below, you’ll find the edited Dockerfile that I’ve been using:
FROM balenalib/raspberrypi4-64-debian:latest

Install dependencies

RUN apt-get update &&
apt-get install -yq
python3
python3-dev
python3-pip
python3-setuptools
gstreamer-1.0
v4l-utils
libopus-dev
libvpx-dev
libvpx6
libopus0
libsrtp2-dev
libopencv-dev
libatlas3-base
libatlas3-base libgfortran5
libatlas-base-dev
libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev \
python3-dev python3-numpy ffmpeg cmake-qt-gui libopenblas-dev
tesseract-ocr libtesseract-dev libprotobuf-dev libleveldb-dev
libhdf5-serial-dev protobuf-compiler libatlas-base-dev
gfortran libgstreamer1.0-dev libatlas-base-dev libxvidcore-dev
libpng-dev libopenexr-dev libtiff-dev libwebp-dev
libmp3lame-dev libtheora-dev libvorbis-dev
libqt5widgets5 libqt5gui5 libqt5dbus5 libqt5network5 libqt5core5a
libavformat-dev
libswscale-dev
libavdevice-dev
libavfilter-dev
libavcodec-dev
libavdevice-dev libavfilter-dev libopus-dev libvpx-dev pkg-config
&& apt-get clean && rm -rf /var/lib/apt/lists/*

Enable the v4l2 driver for the Raspberry Pi camera

#RUN printf “bcm2835-v4l2\n” >> /etc/modules
RUN pip3 install --upgrade pip
RUN pip3 install async-timeout av==10.0.0
RUN pip install multidict
RUN pip install aiohttp
RUN pip3 install websocket-client==1.5.2 aiohttp-basicauth==1.0.0 aioice==0.9.0 --index-url piwheels - Simple index
RUN pip3 install numpy
RUN pip3 install aiortc

1 Like

Hello @Mathan first of all welcome to the balena community!

As you mention the balena-cam used to work on 32 bits in the past.

Could you please confirm what camera are you using?

On the other hand, is there any error on the Logs that you can share? I have seen some messages on the Edge Impulse forums about it such as Failed to initialize linux tool Capture process failed with code 1 - Report bugs - Edge Impulse

Keep us updated with this! Thanks!

Hey @mpous, thank you. Is there any existing 32bit version that i can use? i don’t seem to see that option when selecting the type of OS. Im using Pi camera v1. I have attached some log files while i was troubleshooting. The latest “working” is version 3 while 1 and 2 are intermediate releases that failed. However, as I mentioned when I run the app, it hangs when the webRTC establishes a connection. Really appreciate if hope you could assist me with this.
Version-3(successful build).txt (2.0 KB)
Version-2.txt (203.8 KB)
Version-1.txt (5.8 KB)

Hi, I tried several times playing around with the dockerfile to get balena-cam to work but was unable to do so. Are there any alternatives available or could I be able to gain access to the 32-bit os so that I could get that service running? I hope I could get an assist on that matter.

Hello @mathan balenaCam probably needs a rewrite to be used on modern OS releases (it is almost five years old at this point) - I started a rewrite using blocks a while back. That version does work on the Pi4. You can clone it with git clone -b alanb128-blocks --single-branch https://github.com/balena-labs-projects/balena-cam.git and integrate it with the Edge Impulse example repo.