CAMZ is a lightweight, low-latency, cross-platform open-source camera dashboard and video surveillance system. Designed to run efficiently on everything from a Raspberry Pi OS setup to macOS, Linux, and Windows 10/11 desktops, CAMZ decouples camera feed acquisition, motion detection, web streaming, and automated disk-quota recording into discrete asynchronous pipelines.
graph TD
Camera[Camera Source: OpenCV / Picamera2]
Capture[Capture Thread: camera_manager.py]
LatestBuffer[Latest Frame Buffer]
Camera -->|Pull Frame| Capture
Capture -->|Store Frame| LatestBuffer
subgraph Pipelines [Independent Asynchronous Engines]
Detector[Motion Detector Thread]
Encoder[JPEG Encoder Thread]
Recorder[Recorder Queue Worker]
end
LatestBuffer -.->|Read Read-only| Detector
LatestBuffer -.->|Read Read-only| Encoder
LatestBuffer -.->|Read Read-only| Recorder
Encoder -->|Cache JPEG Bytes| HTTPStream[HTTP MJPEG Stream]
Detector -->|Motion Detected| Recorder
Recorder -->|Write MP4| StorageManager[StorageManager Quota Cleanup]
- Decoupled Pipelines: Capture, motion analysis, streaming, and recording run on separate threads. Slow disk operations never block live streams.
- Micro-Buffered Recording: Circular pre-buffers (defaults to 5s) and post-buffers (defaults to 10s) ensure you never miss the start or end of motion events.
- Aesthetic Dashboard: Premium Vercel/Linear-inspired interface featuring live system load graphs, scrolling log console, settings validators, and interactive video playback.
- Dynamic Quotas: Intelligent storage limits controller automatically sweeps old recordings oldest-first when disk threshold is hit.
- Cross-Platform Setup: Unified bootstrap utilities for Windows (PowerShell) and Linux/macOS (Bash).
- Graceful Failbacks: Automatically detects Picamera2, video sources, hardware encoders, and reverts to stable software/OpenCV fallbacks if absent.
- Backend: Python 3.10+, FastAPI (ASGI server), OpenCV, NumPy, Uvicorn, Pillow, psutil.
- Frontend: React 19, TypeScript, Vite, TailwindCSS v4, Zustand (state store), React Router v7, Recharts, Framer Motion, Lucide Icons.
CAMZ provides automatic capability checking. It will detect your platform configurations and hardware constraints automatically.
Open your terminal and run the one-command installer:
./setup.shThis script provisions the Python virtual environment (.venv), installs all dependency wheels, runs platform diagnostics, installs frontend assets, and pre-compiles the React production bundle under frontend/dist.
Open PowerShell as an Administrator and execute:
Set-ExecutionPolicy RemoteSigned -Scope Process
.\setup.ps1If using the official Raspberry Pi camera, install system packages first:
sudo apt install -y python3-picamera2 libcamera-apps
./setup.shTo start the system, run the bootstrap script corresponding to your platform.
./run.sh.\run.ps1This starts the ASGI Uvicorn app. Open http://127.0.0.1:8000 in your web browser.
CAMZ reads configuration options from standard environment variables (or local .env files).
| Variable | Default | Description |
|---|---|---|
CAMZ_CAMERA_INDEX |
0 |
Default camera device index (OpenCV). |
CAMZ_USE_PICAMERA2 |
0 |
Force Picamera2 source on Raspberry Pi. |
CAMZ_STREAM_FPS |
20 |
Streaming frame rate target (FastAPI proxy). |
CAMZ_RECORDING_FPS |
20 |
Video writer recording output frame rate. |
CAMZ_STORAGE_LIMIT_GB |
50 |
Maximum disk storage usage allowed for recordings. |
CAMZ_RETENTION_DAYS |
30 |
Age cutoff in days to retain recording files. |
CAMZ_PREBUFFER_SECONDS |
5 |
Pre-motion buffer duration in seconds. |
CAMZ_POSTBUFFER_SECONDS |
10 |
Post-motion recording cooldown duration. |
CAMZ/
βββ backend/ # Python backend package
β βββ main.py # FastAPI application entry point
β βββ api/ # HTTP route handlers (stream.py)
β βββ camera/ # Camera acquisition layer
β β βββ camera.py # OpenCV / Picamera2 device wrapper
β β βββ camera_manager.py # Capture thread, latest-frame buffer
β βββ config/ # System configuration
β β βββ config.py # Environment variable reader
β βββ detection/ # Motion analysis
β β βββ detector.py # OpenCV-based motion detector
β βββ health/ # Subsystem health reporting
β β βββ health.py # Build health report utility
β βββ metrics/ # Performance counters
β β βββ metrics.py # FPS counter, uptime tracker
β βββ recording/ # Async recording pipeline
β β βββ recorder.py # Queue-worker, pre/post-buffer engine
β β βββ recording_manager.py # Session, metadata & thumbnail writer
β β βββ video_encoder.py # OpenCV VideoWriter wrapper
β βββ storage/ # Disk management
β β βββ storage_manager.py # Quota enforcement + RuntimeStorageManager
β βββ utils/ # Shared utilities
β βββ utils.py # Logging bootstrap, directory setup
βββ frontend/ # React SPA (Vite + TypeScript + Tailwind v4)
β βββ src/
β β βββ components/ # Layout components (Sidebar, TopBar, etc.)
β β βββ pages/ # Route pages (Dashboard, LiveView, etc.)
β β βββ store/ # Zustand global state
β βββ dist/ # Compiled production bundle (git-ignored)
βββ runtime/ # All generated data (git-ignored)
β βββ recordings/ # MP4 video files + JSON metadata
β βββ snapshots/ # Captured JPEG snapshots
β βββ logs/ # Application log files
β βββ cache/ # Internal caching layer
β βββ settings.json # Persisted user settings
βββ static/ # Legacy static assets
βββ templates/ # Jinja2 HTML templates (fallback)
βββ tests/ # Pytest unit and integration tests
βββ scripts/ # Benchmark, endurance, and platform tools
βββ run.sh / run.ps1 # Platform launch scripts
βββ setup.sh / setup.ps1 # Platform install scripts
βββ verify.sh / verify.ps1 # CI verification scripts
GET /: Serves the React SPA Dashboard index.GET /snapshot: Captures and returns a unique timestamped JPEG.GET /stream.mjpeg: Dynamic MJPEG video feed.GET /health: Detailed subsystem diagnostic report.GET /recordings: JSON list of saved recording sessions.GET /recordings/{id}: Serve the recording MP4 file.DELETE /recordings/{id}: Permanently delete a recording.GET /storage: Current quota usage and limits report.GET /settings: Fetch dashboard settings.POST /settings: Dynamic configuration updates (saves tosettings.json).GET /logs: Tail logs buffer.POST /camera/restart: Reload and restart camera capture feed.
This project is open-source and licensed under the MIT License.