An AI-powered surveillance system with real-time threat detection. This streamlined codebase supports a modern web interface and a simple CLI stream. Desktop GUI has been removed for a cleaner structure.
- Real-time CCTV footage streaming with low-latency playback
- Smooth video processing at configurable FPS (default: 30 FPS)
- Support for webcam and IP cameras with easy configuration
- Fullscreen mode support in web interface
- Responsive video display that adapts to different screen sizes
- YOLOv8-based object detection with 80+ COCO dataset objects
- Real-time bounding box visualization with confidence scores
- Dynamic object labeling on video feed
- Color-coded detection boxes (red for threats, green for normal objects)
- Configurable confidence thresholds for detection accuracy
- Automatic threat detection for weapons, violence, and suspicious activities
- Visual alert indicators with color coding and animations
- Audio alert notifications using Web Audio API
- SMS integration via Twilio for immediate notifications
- Emergency stop functionality for critical situations
- Alert cooldown system to prevent spam notifications
- Clean, responsive web interface with live stats and logs
- Mobile/tablet responsive design for remote monitoring
- Dark mode styling and WebSocket real-time updates
- Python 3.8+
- Webcam or IP camera
- CUDA-compatible GPU (optional, for faster processing)
- Twilio account (for SMS alerts)
-
Clone the repository
git clone <repository-url> cd IntelliGuardAI
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
# Copy the example environment file cp .env.example .env # Edit .env with your Twilio credentials (for SMS alerts) # Get credentials from https://console.twilio.com/
-
Configure the system (optional)
# Edit config.py to customize settings # Or set environment variables export CAMERA_SOURCE=0 export CONFIDENCE_THRESHOLD=0.5 export SMS_ENABLED=true
python main.py- URL: http://localhost:8000/web
- Features: Live video feed, real-time alerts, statistics, logs
- Best for: Remote monitoring, multiple users, mobile access
python detect_stream.py- Features: Terminal-based detection, SMS alerts, console output
- Best for: Server deployment, automated monitoring, logging
- Real-time camera stream with detection overlays
- Fullscreen mode support
- Automatic refresh and reconnection
- Responsive design for all devices
- Visual threat indicators with animations
- Audio alert notifications
- Alert history and details
- Emergency stop button
- Total detections counter
- Active threats counter
- Real-time detection list
- System status indicators
- Live detection logs
- Threat-specific highlighting
- Timestamp information
- Scrollable history
# config.py
CAMERA_SOURCE = 0 # Camera index or IP camera URL
CAMERA_WIDTH = 640 # Video width
CAMERA_HEIGHT = 480 # Video height
CAMERA_FPS = 30 # Frames per secondMODEL_PATH = "yolov8n.pt" # YOLO model file
CONFIDENCE_THRESHOLD = 0.5 # Detection confidence (0.0-1.0)
USE_GPU = True # Enable GPU accelerationTHREAT_OBJECTS = [
'knife', 'gun', 'fight', 'snatching',
'weapon', 'pistol', 'rifle', 'assault'
]
ALERT_COOLDOWN = 30 # Seconds between alertsSMS alerts require a Twilio account. Configure via environment variables:
# Create .env file from template
cp .env.example .env
# Edit .env with your Twilio credentials
# Get credentials from https://console.twilio.com/Environment variables:
SMS_ENABLED=true
TWILIO_ACCOUNT_SID=your_account_sid
TWILIO_AUTH_TOKEN=your_auth_token
TWILIO_PHONE_NUMBER=+1234567890
TARGET_PHONE_NUMBER=+0987654321
β οΈ Never commit your actual credentials to version control!
- People: person, child, adult, man, woman
- Vehicles: car, truck, bus, motorcycle, bicycle
- Animals: dog, cat, bird, horse, cow
- Objects: chair, table, phone, laptop, book
- And many more...
- Weapons: knife, gun, weapon, pistol, rifle
- Violence: fight, assault, attack
- Crime: snatching, theft, robbery
- Custom: Add your own threat categories
- Automatic CUDA detection and usage
- Significant performance improvement with NVIDIA GPUs
- Fallback to CPU if GPU unavailable
- Use smaller models (yolov8n) for speed
- Use larger models (yolov8l, yolov8x) for accuracy
- Adjustable confidence thresholds
- Minimum: 4GB RAM, CPU-only
- Recommended: 8GB+ RAM, CUDA GPU
- Optimal: 16GB+ RAM, RTX 3060+ GPU
- Configurable CORS settings
- Rate limiting support
- API key authentication (optional)
- HTTPS support
- Local processing (no cloud dependencies)
- Configurable data retention
- Secure log storage
- User consent mechanisms
Camera not detected:
# Check camera permissions
# Try different camera index
# Update config.py: CAMERA_SOURCE = 1Model loading error:
# Model will be downloaded automatically
# Or download manually:
wget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.ptPerformance issues:
# Reduce resolution in config.py
CAMERA_WIDTH = 320
CAMERA_HEIGHT = 240SMS not sending:
- Create
.envfile from.env.example - Add your Twilio credentials to
.env - Verify phone number format (+country code)
- Ensure sufficient Twilio credits
- Check console output for errors
- Monitor system resources
- Verify camera permissions
- Test with sample images
# In config.py
THREAT_OBJECTS = [
'knife', 'gun', 'fight', 'snatching',
'your_custom_threat' # Add your own
]ALERT_MESSAGES = {
'knife': 'β οΈ Knife detected! Potential threat identified.',
'your_threat': 'π¨ Your custom alert message!'
}# Add custom alert handling in your interface
def custom_alert_handler(threat_type, confidence):
# Your custom logic here
passGET /- Health checkGET /web- Web interfaceGET /video_feed- Live video streamGET /api/status- System statusGET /api/threats- Current threatsGET /api/logs- Detection logs
POST /analyze- Analyze uploaded imageWebSocket /ws- Real-time updates
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ultralytics for YOLOv8 implementation
- OpenCV for computer vision capabilities
- FastAPI for web framework
- Twilio for SMS integration
- Font Awesome for icons