An end-to-end system that detects weapons (guns/knives), recognizes faces, and maintains a persistent list of criminals. The system triggers alarms and captures evidence on criminal detection.
Traditional CCTV lacks real-time context. This project fuses face recognition and weapon detection to: (1) flag unknown individuals holding weapons, (2) enforce per-user weapon permissions, and (3) instantly alert on known criminals with visual evidence.
The pipeline combines a YOLO-based detector with LBPH face recognition, maintaining user modes and a criminals registry.
- Unknown person holding weapon (gun/knife): Add to
criminals.jsonfor future detection. - Known person with modes (allowed / not allowed): If not allowed and holding weapon → add to criminals.
- Criminal detected (with or without weapon): Play alarm and capture screenshot.
- Face Recognition: YOLOv8 face detection + LBPH recognizer (
trainneruser.yml). - Weapon Detection: YOLOv8 model detecting guns and knives.
- Criminal Registry:
criminals.jsonmaintained by the pipeline andtracker.py.
- Weapon model demo (guns/knives): [YouTube link]
- Full pipeline demo (faces + modes + alarm + screenshots): [YouTube link pending]
Below is the normalized confusion matrix for the weapon detector. Use it to understand class-wise performance and common confusions.
Install Python 3.9+ and dependencies:
pip install -r requirments.txt- Ensure
users.jsonandtrainneruser.ymlexist for known users. - Use
create.pyto register a new user (captures 60 face images and retrains).
- Use GUI:
pyhton GUI.py - Register user:
python create.pyor click onCreatebutton in GUI - Recognize / monitor users: use
detector()indetector.pyor click onlive face Detectbutton in GUI - Criminal capture flow (screenshots + retrain):
python tracker.py - Weapon-only demo:
python weaponDetect.pyor click onlive weaponbutton in GUI - Combined live demo (faces + weapons): use
live_detection()indetector.pyor click onlive Detectionbutton in GUI
create.py # Register user and retrain
detector.py # Face recognition, criminals, live detection
tracker.py # Hand/object overlap, capture screenshots, update criminals
weaponDetect.py # Weapon-only detection demo
trainner.py # Training utilities (LBPH)
users.json # Known users with modes (allowed / not allowed)
criminals.json # Criminal registry
models/ # Model weights (YOLO)
static/, templates/ # Web/static assets (if applicable)
Use responsibly and comply with local laws and privacy regulations. Models may exhibit bias or errors; always keep a human in the loop for critical decisions.
Supervisor: Dr/Wael Zakriya
Contributions are welcome! Feel free to open issues or PRs.













