A real-time threat detection system using computer vision and machine learning to identify potentially dangerous objects (firearms and fire) and provide instant email notifications with visual evidence.
Made with ❤️, for Safety 🦺
- Real-time detection of guns, rifles, and fire in video streams
- Automated email notifications with captured images
- Easy-to-use interface for security monitoring
- Configurable alert thresholds and notification settings
- Python 3.8+
- OpenCV 4.5+
- CUDA support (optional, for GPU acceleration)
- Webcam or USB camera
- Minimum 4GB RAM
- x86_64 architecture
- Git (for cloning)
- Clone the repository:
git clone https://github.com/phanindra-max/danger-detection-with-ml.git
cd danger-detection-with-ml
- Create and activate a virtual environment:
python -m venv venv
venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
Your requirements.txt
should contain:
opencv-python>=4.5.0
numpy>=1.19.0
argparse>=1.4.0
- Download YOLOv3 weights and config:
# Download weights
curl -L https://pjreddie.com/media/files/yolov3.weights -o yolov3.weights
# Download config
curl -L https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg -o yolov3.cfg
- Create obj.names file:
Create a new file named
obj.names
with the following content:
gun
rifle
fire
-
Setup Gmail Authentication:
- Enable 2-Factor Authentication in your Gmail account
- Generate an App Password:
- Go to Google Account → Security → App Passwords
- Select "Mail" and "Windows Computer"
- Copy the 16-digit password
-
Update Email Settings:
# In main.py, update these variables:
mailfrom = "<[email protected]>"
gmailpass = "<your-16-digit-app-password>"
mailto = "<[email protected]>"
python main.py [--webcam True/False] [--image True/False] [--image_path PATH] [--verbose True/False]
Options:
--webcam
: Enable webcam mode--image
: Enable image mode--image_path
: Path to input image (default: "use-this.jpg")--verbose
: Enable verbose output
python main.py
When prompted, enter 'Y' to start webcam detection.
- Average processing speed: 25 FPS on CPU
- GPU acceleration available with CUDA support
- Accuracy depends on image quality and lighting conditions
We welcome contributions! Please see Contributing Guidelines.
- YOLOv3 team for the detection model
- OpenCV community for vision tools
- Add support for more object types
-
Implement real-time API(Abandoned due to monetary constraints) - Improve detection accuracy
- Add cloud deployment options
Made with ❤️ for Safety 🦺