diff --git a/balena-cam/Dockerfile.aarch64 b/balena-cam/Dockerfile.aarch64 index 2ecbaaa..d285f85 100644 --- a/balena-cam/Dockerfile.aarch64 +++ b/balena-cam/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM balenalib/raspberrypi3-debian:stretch-20190612 +FROM balenalib/raspberrypi3-debian:buster # Install dependencies RUN apt-get update && \ @@ -16,8 +16,8 @@ RUN apt-get update && \ libatlas3-base \ libatlas-base-dev \ libjasper-dev \ - libilmbase12 \ - libopenexr22 \ + libilmbase23 \ + libopenexr23 \ libavformat-dev \ libswscale-dev \ libqtgui4 \ @@ -29,9 +29,11 @@ RUN apt-get update && \ # 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==6.1.0 -RUN pip3 install pyee==8.2.2 aiohttp aiohttp_basicauth==0.1.3 aioice==0.6.10 aiortc==0.9.11 numpy==1.15.4 opencv-python==3.4.4.19 --index-url https://www.piwheels.org/simple + +RUN python3 -m pip install --upgrade pip setuptools wheel +RUN python3 -m pip install async-timeout av --index-url https://www.piwheels.org/simple +RUN python3 -m pip install -U aiohttp[speedups] aiohttp_basicauth aioice aiortc numpy opencv-python-headless --index-url https://www.piwheels.org/simple + WORKDIR /usr/src/app diff --git a/balena-cam/Dockerfile.template b/balena-cam/Dockerfile.template index fe8025f..8b20044 100644 --- a/balena-cam/Dockerfile.template +++ b/balena-cam/Dockerfile.template @@ -1,4 +1,4 @@ -FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:stretch-20190612 +FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:buster # Install dependencies RUN apt-get update && \ @@ -16,8 +16,8 @@ RUN apt-get update && \ libatlas3-base \ libatlas-base-dev \ libjasper-dev \ - libilmbase12 \ - libopenexr22 \ + libilmbase23 \ + libopenexr23 \ libavformat-dev \ libswscale-dev \ libqtgui4 \ @@ -29,9 +29,10 @@ RUN apt-get update && \ # 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==6.1.0 -RUN pip3 install pyee==8.2.2 aiohttp aiohttp_basicauth==0.1.3 aioice==0.6.10 aiortc==0.9.11 numpy==1.15.4 opencv-python==3.4.4.19 --index-url https://www.piwheels.org/simple + +RUN python3 -m pip install --upgrade pip setuptools wheel +RUN python3 -m pip install async-timeout av --index-url https://www.piwheels.org/simple +RUN python3 -m pip install -U aiohttp[speedups] aiohttp_basicauth aioice aiortc numpy opencv-python-headless --index-url https://www.piwheels.org/simple WORKDIR /usr/src/app diff --git a/balena-cam/app/server.py b/balena-cam/app/server.py index ad1c55d..760a76b 100644 --- a/balena-cam/app/server.py +++ b/balena-cam/app/server.py @@ -1,4 +1,4 @@ -import asyncio, json, os, cv2, platform, sys +import asyncio, json, os, cv2, platform, subprocess, sys from time import sleep from aiohttp import web from av import VideoFrame @@ -165,10 +165,17 @@ async def on_shutdown(app): await asyncio.gather(*coros) def checkDeviceReadiness(): + # TODO : check user is in video group ! + # TODO : check if we are on a RPI if not os.path.exists('/dev/video0') and platform.system() == 'Linux': print('Video device is not ready') print('Trying to load bcm2835-v4l2 driver...') - os.system('bash -c "modprobe bcm2835-v4l2"') + try: + subprocess.run(['modprobe', 'bcm2835-v4l2'], check=True) + except FileNotFoundError: + print("Cannot modeprobe bcm2835-v4l2, not a Raspberry-Pi ?") + except subprocess.CalledProcessError as err: + print(err) sleep(1) sys.exit() else: @@ -202,7 +209,7 @@ def checkDeviceReadiness(): print('Set the username and password environment variables \nto enable authorization.') print('For more info visit: \nhttps://github.com/balena-io-playground/balena-cam') print('#############################################################\n') - + # Factory to create peerConnections depending on the iceServers set by user pc_factory = PeerConnectionFactory()