SentryVision is an advanced system that detects fast-moving thrown objects (such as sacks, stones, or tools) entering a user-defined critical region in real-time video feeds. It is designed to minimize false positives from birds, animals, and natural environmental motion using state-of-the-art computer vision techniques.
- Real-time video input from webcam, RTSP streams, or video files
- Interactive ROI (Region of Interest) selection with visual feedback
- Advanced background subtraction (MOG2) with adaptive learning
- High-speed motion and size filtering with configurable thresholds
- Morphological noise reduction and contour analysis
- Visual and console alerts with comprehensive event logging
- Automatic snapshot saving on detection with metadata
- Robust error handling and system recovery
- Modern web-based dashboard with real-time monitoring
- Event database with search and export capabilities
- Video recording and playback functionality
main.py: Main application and GUI interfaceapp.py: Web-based dashboard and API endpointsmotion_detector.py: Advanced motion detection logic with object trackingroi_manager.py: ROI selection and management with persistencealert_system.py: Alert generation and logging systemevent_db.py: Event database management and queryingconfig.py: Configurable parameters and system settingsrequirements.txt: Python dependenciestemplates/: Web interface HTML templatesapi/: API endpoints and dashboard logic
- Install dependencies:
pip install -r requirements.txt
- Run the web dashboard:
python app.py
- Run the desktop GUI (optional):
python main.py
- Web Interface: Open browser to
http://localhost:5000 - ROI Selection: Draw region of interest on video feed
- Detection Control: Start/stop detection and recording
- Event Review: Browse detected events and snapshots
- Settings: Adjust detection parameters in real-time
SentryVision is production-ready with Gunicorn and Nginx support.
- Install Nginx for reverse proxy
- Run web interface:
gunicorn --worker-class eventlet -w 1 -b 0.0.0.0:5000 app:app
- Run with multiple workers for scalability:
gunicorn --worker-class eventlet -w 4 -b 0.0.0.0:5000 app:app
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Static file serving
location /static/ {
alias /path/to/sentryvision/static/;
expires 30d;
}
}- Use load balancer with sticky sessions for multiple workers
- Enable gzip compression in Nginx
- Configure proper caching headers
- Monitor system resources and adjust worker count accordingly
- Input validation and sanitization
- Secure file upload handling
- SQL injection prevention
- XSS protection
- Rate limiting support
- Event logging with structured data
- Performance metrics collection
- Automatic error recovery
- Database maintenance utilities