Skip to content

Security detection project to detect weapons(Knife, guns) contain other features. finished by Ainshams Students

Notifications You must be signed in to change notification settings

UDJAT74/Security_Dtection

Repository files navigation

Security Detection: Face, Weapon, and Criminal Recognition (Real-time)

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.

Problem Description

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.

How It Works (Overview)

The pipeline combines a YOLO-based detector with LBPH face recognition, maintaining user modes and a criminals registry.

System Architecture

Core Logic: Three Cases

  • Unknown person holding weapon (gun/knife): Add to criminals.json for 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.

Model Components

  • Face Recognition: YOLOv8 face detection + LBPH recognizer (trainneruser.yml).
  • Weapon Detection: YOLOv8 model detecting guns and knives.
  • Criminal Registry: criminals.json maintained by the pipeline and tracker.py.

Real-time Demo

  • Weapon model demo (guns/knives): [YouTube link]
  • Full pipeline demo (faces + modes + alarm + screenshots): [YouTube link pending]

Gun Detection Screenshots Example

gun1 gun2 gun3 gun4 gun5 gun6

Knife Detection Screenshots Example

shot1 shot3 shot4 shot5 shot6

Confusion Matrix

Below is the normalized confusion matrix for the weapon detector. Use it to understand class-wise performance and common confusions.

Confusion Matrix


Quick Start

Requirements

Install Python 3.9+ and dependencies:

pip install -r requirments.txt

Prepare Data

  • Ensure users.json and trainneruser.yml exist for known users.
  • Use create.py to register a new user (captures 60 face images and retrains).

GUI

image

Run

  • Use GUI: pyhton GUI.py
  • Register user: python create.py or click on Create button in GUI
  • Recognize / monitor users: use detector() in detector.py or click on live face Detect button in GUI
  • Criminal capture flow (screenshots + retrain): python tracker.py
  • Weapon-only demo: python weaponDetect.py or click on live weapon button in GUI
  • Combined live demo (faces + weapons): use live_detection() in detector.py or click on live Detection button in GUI

Project Structure (Key Files)

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)

Ethics & Disclaimer

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.


Contributors

Supervisor: Dr/Wael Zakriya

  1. Ahmed Abdelgelel
  2. Ahmed Salem
  3. Youssef Tarek
  4. Mohamed Medhat

Contributing

Contributions are welcome! Feel free to open issues or PRs.

About

Security detection project to detect weapons(Knife, guns) contain other features. finished by Ainshams Students

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •