This repo contains code used to run the Monash Human Power camera system for V4. The master
branch is write protected to ensure it is always left in a working state.
-
Setup
.env
fileDuplicate
.env.example
into.env
and alter the environment variables accordingly. This file is how the overlay knows whether it is primary or secondary, the bike it is on, the broker IP and the screen resolution. -
Configure
config.json
Optionally, you may set the overlay to run when the physical switch on the display is toggled by modifying
config.json
. An example of this file's contents could be{ "activeOverlay": "overlay_all_stats.py" }
. -
Install Python 3.7 with
pyenv
At this point in time, you'll also need Python 3.7 installed, as currently, the OpenCV version we are using does not have a build available for Python 3.8. pyenv may be used to quickly switch between python versions. To do this,
- Install
pyenv
.- Linux installation (including Pi) here. You may need to install these dependencies from here (use Debian dependencies fo the Raspbery Pi)
- macOS installation: See pyenv's github
- Windows installation: See pyenv-win
- Install Python 3.7 with
pyenv install 3.7.7
, - and finally, set it as your current python version with
pyenv local 3.7.7
.
- Install
-
Install OpenCV dependencies
You will likely need to install some dependencies for OpenCV to run, especially if you are on a Raspberry Pi. To do this, run
sudo apt install libgtk-3-0 libavformat58 libtiff5 libcairo2 libqt4-test libpango-1.0-0 libopenexr23 libavcodec58 libilmbase23 libatk1.0-0 libpangocairo-1.0-0 libwebp6 libqtgui4 libavutil56 libjasper1 libqtcore4 libcairo-gobject2 libswscale5 libgdk-pixbuf2.0-0
-
Install poetry and python dependencies
To install dependencies, you will need poetry installed on your computer.
With that done,
raspicam
dependencies may be installed usingpoetry install --dev
. -
Install and enable
systemd
services (optional)If you are setting up
raspicam
on the actual display Pis, enable and start theraspicam
services so thatraspicam
begins on startup.# Install the raspicam services ./service/install.sh # Enable running on boot, and start running now systemctl --user enable --now raspicam-orchestrator systemctl --user enable --now raspicam-switch
Important: You must be in a poetry shell to run any scripts/tests. To start a poetry shell, run poetry shell
. You may exit the shell at any time with exit
.
Any overlay (e.g. overlay_top_strip.py
) may be run from the terminal with Python. If your computer does not have a webcam, you may replace the video feed with a static background specified with the --bg
option. The --host
argument can be used to specify an MQTT broker.
If you are trying run an overlay over VNC, you will need to enable direct capture mode on the Pi's VNC server. Right click on the VNC logo in the Pi's system tray, click Options -> Troubleshooting -> Enable direct capture mode -> OK
.
Overlays may be run from the terminal, as before. However, for use on the bike, you should have switch.py
and orchestrator.py
running on startup using systemd services as described in Installation. Once this is setup, you can view the output of the two scripts with
systemctl --user status raspicam-orchestrator
You may also find systemctl
's start
, stop
, restart
and disable
commands useful.
Located under tests
. Enter pytest
in the terminal to run all tests.
mqtt_message_test.py
: Script that sends messages to the camera overlay. First, run mqtt_message_test.py
along with mqtt_test.py
from the DAS repo, Finally run overlay_all_stats.py
.
Thanks goes to these wonderful people (emoji key):
pdgra1 💻 |
Angus Lee 💻 |
Harsil Patel 💻 |
Laksh Jaisinghani 💻 |
Christopher Hall 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!