Now we are ready to install last missing dependencies and setup OTCamera.
Setup Python and Dependencies¶
By default, Raspberry OS light doesn't come with PIP and git installed. We will need it to install required packages.
sudo apt install python3-pip git -y
If you are using RaspberryPi OS legacy
Since the latest RaspberryPi OS python3 is the default python version. If you are using (not recommended) an older version of RaspberryPi OS, you need to make python3 your default version.
Raspberry OS legacy ships with python 2 and python 3. By default python 2 is used. We want to change that to python 3 by adding two single lines to
echo "alias python='/usr/bin/python3'" >> ~/.bashrc echo "alias pip=pip3" >> ~/.bashrc source ~/.bashrc python --version pip --version
Both commands should state, that they are (using) python 3.(x).
We'll need to download OTCamera using git to get all the code we'll need to run OTCamera.
git clone --depth 1 https://github.com/OpenTrafficCam/OTCamera.git
OTCamera requires additional python packages, which need to be installed.
cd OTCamera pip install -r requirements.txt --upgrade
Setup Webserver for Preview¶
We are currently using nginx (a small webserver) to serve a small HTML file including a preview of the camera view.
To install nginx:
sudo apt install nginx -y
We need to configure nginx to serve the OTCamera GUI.
Open the nginx config file
/etc/nginx/sites-available/default and edit the webserver root.
sudo nano /etc/nginx/sites-available/default
You should see something like this (there may be some comment lines starting with # which you can ignore).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The important line we need to change is highlighted.
/var/www/html with the full path to the
If your username is
pi it should be
Restart nginx afterwards to let it know about the new directory:
sudo systemctl restart nginx.service
Start OTCamera on startup¶
Now we want to start OTCamera every time the Raspberry starts.
To do so, we will setup and enable a service.
otcamera.service inside the OTCamera repository according to your username and path.
1 2 3 4 5 6 7 8 9 10 11 12 13
Now copy the file to
/lib/systemd/system and enable it:
sudo cp ./raspi-files/otcamera.service /lib/systemd/system sudo systemctl daemon-reload systemctl enable otcamera.service
After rebooting the Raspberry you should be able to access it's Wi-Fi ap and to open the OTCamera status site using the Raspberry's ip address: http://10.10.50.1