Manual raspiCamSrv Installation
The following procedure describes a manual step by step installation.
For automatic installation, see RaspiCamSrv Installation.
If you want to update an existing installation to the latest version, see Update Procedure.
In case of problems during installation and usage, see Troubleshooting
NOTE: For Debian-Trixie, some of the required packages are already preinstalled. To ensure everything is consistently installed in and run from the raspiCamSrv virtual environment, the respective pip install commands, below, have been extended with a --ignore-installed clause and the Flask server is started with python -m flask ...
- Connect to the Pi using SSH:
ssh <user>@<host>
withand as specified during setup with Imager. - Update the system
sudo apt updatesudo apt full-upgrade - If you intend to take videos and have installed a lite version of the OS, you may need to install ffmpeg:
Check whether ffmpeg is installed withwhich ffmpeg
If you get an empty response, install withsudo apt install ffmpeg - Create a root directory under which you will install programs (e.g. 'prg')
mkdir prgcd prg - Check that git is installed (which is usually the case in current Bullseye, Bookworm or Trixie distributions)
git --version
If git is not installed, install it withsudo apt install git - Clone the raspi-cam-srv repository:
git clone --branch main --single-branch https://github.com/signag/raspi-cam-srv - Create a virtual environment ('.venv') on the 'raspi-cam-srv' folder:
cd raspi-cam-srvpython -m venv --system-site-packages .venv
For the reasoning to include system site packages, see the picamera2-manual.pdf, chapter 9.5. - Activate the virtual environment
cd ~/prg/raspi-cam-srvsource .venv/bin/activate
The active virtual environment is indicated by(.venv)preceeding the system prompt.
(If you need to leave the virtual environment at some time, usedeactivate) - Trixie: Skip this step!
Make sure that picamera2 is available on the system:python>>>import picamera2>>>quit()
If you get a 'ModuleNotFoundError', see the picamera2 Manual, chapter 2.2, how to install picamera2.
For raspiCamSrv it would be sufficient to install without GUI dependencies:sudo apt install -y python3-picamera2 --no-install-recommends - Install Flask 3.x with the virtual environment activated (Step 8).
Raspberry Pi OS distributions come with Flask preinstalled, however we need to run Flask from the virtual environment in order to see other packages which will be located there.pip install --ignore-installed "Flask>=3,<4"
Make sure that Flask is really installed in the virtual environment:which flaskshould output/home/<user>/prg/raspi-cam-srv/.venv/bin/flask - Optional installations:
The following installations are only required if you need to visualize histograms of photos or if you are interested in using Extended Motion Capturing Algorithms or Stereo Vision.
For use of USB cameras, OpenCV is required.
All installations must be done with the virtual environment activated (Step 8)
Install OpenCV:sudo apt-get install python3-opencv
Install numpy:pip install --ignore-installed numpy
(There may be errors, which normally can be ignored)
Install matplotlib:
Trixie:pip install --ignore-installed matplotlib
(There may be errors, which normally can be ignored)
Bookworm:pip install --ignore-installed "matplotlib<3.8"
(The version restriction assures compatibility with numpy 1.x which is required for Picamera2)
The following installation is required for enabling the raspiCamSrv API
Install flask-jwt-extended:pip install --ignore-installed flask-jwt-extended
(There may be errors, which normally can be ignored) - Initialize the database for Flask
(withraspi-cam-srvas active directory and the virual environment activated - see step 8):python -m flask --app raspiCamSrv init-db - Check that the Flask default port 5000 is available
sudo netstat -nlp | grep 5000
If an entry is shown, find another free port (e.g. 5001)
and replaceport 5000by your port in allflaskcommands, below and also in the URL in step 12. - Start the server
(withraspi-cam-srvas active directory and the virual environment activated - see step 8):python -m flask --app raspiCamSrv run --port 5000 --host=0.0.0.0 - Connect to the server from a browser:
http://<raspi_host>:5000
This will open the Login screen. - Before you can login, you first need to register.
The first user will automatically be SuperUser who can later register other users (User Management) - After successful log-in, the Live screen will be shown, if at least one camera is connected, otherwise the Info screen.
- Done!
- For usage of raspiCamSrv, please refer to the User Guide
When the Flask server starts up, it will show a warning that this is a development server.
This is, in general, fine for private environments.
How to deploy with a production WSGI server, is described in the Flask documentation
