System for controlling multiple cameras
- React
- Fast API
- Python socket
- PostgreSQL
- Bleak BLE
- Vue3
- WebSocket
Requirements
asdf install
Server
cd multi-camera-server
python -m venv .venv
source .venv/bin/activate
python -m pip install .[dev]
cp .env.example .env
Front-end
cd multi-camera-ui
npm install
npm run dev
docker volume create postgres
docker run -d \
-p 127.0.0.1:5432:5432 \
-v postgres:/var/lib/postgresql/data \
--name postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
--restart always \
postgres:14.4
docker exec -it postgres psql "postgres://postgres:mysecretpassword@localhost:5432/postgres" -c "DROP DATABASE camera_db"
docker exec -it postgres psql "postgres://postgres:mysecretpassword@localhost:5432/postgres" -c "CREATE DATABASE camera_db"
Check DB_CONNECTION
from .env
.
NOTE: psycopg
is installed in binary mode.
docker volume create minio
docker run \
-p 9000:9000 \
-p 9090:9090 \
--name minio \
-v minio:/data \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=mysecretpassword" \
--restart always \
quay.io/minio/minio server /data --console-address ":9090"
Create a new access key from http://127.0.0.1:9090/access-keys
.
Update access and secret key from .env
.
# create database
python src/db_create_initial_data.py
# start server
python src/server_main.py
# start camera
python src/camera_main.py
Open server site: http://127.0.0.1:8000/site
Start the camera in dummy mode
python src/camera_main.py --dummy-mode True
Create network to connect containers
docker network create camera-network
docker network connect camera-network postgres
docker network connect camera-network minio
Change connections strings in .env
file
# Use host name instead of IP address
SERVER_HOST="camera-server"
DB_CONNECTION="postgres://postgres:mysecretpassword@postgres:5432/camera_db"
MINIO_ENDPOINT="minio:9000"
# Change host ip and base path
UVICORN_HOST="0.0.0.0"
UVICORN_BASE_PATH="/app/src/"
Start containers
docker build -t camera-system .
docker run --name camera-server --network camera-network -p 8000:8000 --rm camera-system python src/server_main.py
docker run --name camera-camera --network camera-network --rm camera-system python src/camera_main.py --dummy-mode True