OpenCV+YOLO+LLAVA powered video surveillance system
Machina - Video Surveillance System
A simple-to-use AI-powered video surveillance system that can detect and track objects in real-time from cameras, featuring advanced zoom controls, multiple resolution presets, persistent configuration, and smart frame optimization.
What does it do?
Machina watches video feeds and automatically detects objects like people, cars, and other things you care about. It keeps track of each object and can record video or take screenshots when needed.
Key Features:
Runs completely offline - no internet required
Records video and takes snapshots with one key press
Real-time object detection and tracking using YOLO models
Advanced zoom and pan controls with smart object tracking
Crowd detection and clustering algorithms
Instant replay system with 10-second rolling buffer
Multiple resolution presets (640x480 to 1920x1080) with keypad shortcuts
Fullscreen support with aspect ratio preservation
Military mode for enhanced detection accuracy
Smart frame skipping and performance optimization
Dynamic YOLO input size adjustment for optimal performance
Semi-transparent selection overlay with real-time drawing
NEW: Persistent configuration saving - remembers your settings between sessions
NEW: Multi-instance webcam support - automatically detects and configures multiple webcams
Configure your settings:
Edit the top section of app.py to customize:
YOLO model (default: yolo12n)
Video source (RTSP URL or webcam)
Performance settings and thresholds
Run the program:
bash
# For webcam (default)
python app.py
# For specific RTSP stream
python app.py --stream "rtsp://your-camera-url"# For video file
python app.py --stream "path/to/video.mp4"
How to Use
Setting up your camera
You can specify your video source in multiple ways:
Option 1: Command line argument (recommended)
bash
python app.py --stream 0 # Webcam
python app.py --stream "rtsp://camera-url"# IP Camera
python app.py --stream "video.mp4"# Video file
Option 2: Edit app.py configuration
Webcam: Set rtsp_stream = 0
IP Camera: Set rtsp_stream = "rtsp://your-camera-url"
Video File: Set rtsp_stream = "path/to/your/video.mp4"
Controls
Key
What it does
Q
Quit
R
Start/Stop recording
S
Take screenshot
F
Reset window to stream resolution
M
Toggle military mode (enhanced detection)
Space
Skip frames
Backspace
Toggle replay mode
1
Resize to 640x480
2
Resize to 800x600
3
Resize to 1024x768
4
Resize to 1280x800
5
Resize to 1920x1080
6
Reset to original stream size
Enter
Toggle fullscreen mode
Esc
Exit fullscreen mode
+
Decrease frame skip (more processing)
-
Increase frame skip (less processing)
Mouse Controls:
Scroll wheel: Zoom in/out
Right-click + drag: Move around when zoomed
Left-click + drag: Draw selection box
What gets detected
By default, Machina looks for daily objects you can see on street: people, cars, motorcycles etc.
You can change what it looks for by editing the classlist in app.py.
Saved Files
Screenshots: Saved in snapshots/ folder
Recordings: Saved in recordings/ folder
Object images: Saved in elements/ folder
Configuration Files
Machina now automatically saves and loads your settings:
config.json
Stores your application preferences:
Frame skip setting (processing_nth_frame)
Screen resolution preference
Window position
First run detection flag
webcam.json
Automatically detects and stores webcam capabilities: