Skip to content

Manual raspiCamSrv Installation

Up

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 ...

  1. Connect to the Pi using SSH:
    ssh <user>@<host>
    with and as specified during setup with Imager.
  2. Update the system
    sudo apt update
    sudo apt full-upgrade
  3. 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 with
    which ffmpeg
    If you get an empty response, install with
    sudo apt install ffmpeg
  4. Create a root directory under which you will install programs (e.g. 'prg')
    mkdir prg
    cd prg
  5. 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 with
    sudo apt install git
  6. Clone the raspi-cam-srv repository:
    git clone --branch main --single-branch https://github.com/signag/raspi-cam-srv
  7. Create a virtual environment ('.venv') on the 'raspi-cam-srv' folder:
    cd raspi-cam-srv
    python -m venv --system-site-packages .venv
    For the reasoning to include system site packages, see the picamera2-manual.pdf, chapter 9.5.
  8. Activate the virtual environment
    cd ~/prg/raspi-cam-srv
    source .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, use deactivate)
  9. 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
  10. 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 flask should output
    /home/<user>/prg/raspi-cam-srv/.venv/bin/flask
  11. 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)
  12. Initialize the database for Flask
    (with raspi-cam-srv as active directory and the virual environment activated - see step 8):
    python -m flask --app raspiCamSrv init-db
  13. 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 replace port 5000 by your port in all flask commands, below and also in the URL in step 12.
  14. Start the server
    (with raspi-cam-srv as active directory and the virual environment activated - see step 8):
    python -m flask --app raspiCamSrv run --port 5000 --host=0.0.0.0
  15. Connect to the server from a browser:
    http://<raspi_host>:5000
    This will open the Login screen.
  16. Before you can login, you first need to register.
    The first user will automatically be SuperUser who can later register other users (User Management)
  17. After successful log-in, the Live screen will be shown, if at least one camera is connected, otherwise the Info screen.
  18. Done!
  19. 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