Inspiration
With the increasing incidents of public violence, armed attacks, and security threats, we realized the need for a system that can automatically detect dangerous objects like guns and knives in real time. Traditional CCTV cameras only record evidence after an incident occurs — our goal was to create an AI-driven system that detects threats instantly, allowing faster alerts and prevention.
This project was inspired by the idea of using Artificial Intelligence for public safety, combining computer vision and deep learning for real-time monitoring.
We developed a real-time object detection system that can:
Identify weapons such as guns and knives using the YOLOv8 model.
Detect objects from a custom Kaggle dataset.
Perform live detection using a webcam feed.
Automatically save detected frames with labels in a “Detected_Objects” folder.
Provide a simple Tkinter-based user interface with two options:
Detect from Dataset
Real-Time Detection
The system runs on GPU (NVIDIA RTX 4050) or CPU, depending on availability.
Tech Stack
Frontend (UI): Tkinter (Python GUI)
Backend (AI & Processing): YOLOv8 (Ultralytics), OpenCV, PyTorch
Dataset: Guns–Knives Object Detection Dataset (Kaggle)
Languages: Python 🐍
Core Workflow
Preprocessing:
Image resizing and aspect-ratio padding.
Color space conversion to RGB.
Normalization and augmentation for training balance.
Model Inference:
YOLOv8s model used for detection.
Confidence Threshold
0.65 Confidence Threshold=0.65 ensures reliable results.
Output:
Annotated bounding boxes with labels (Gun / Knife).
Frames saved when weapons are detected.
Real-time monitoring through the camera.
What We Learned
Deep understanding of object detection pipelines and YOLO architecture.
How to handle real-time video frames and perform inference using GPU acceleration.
Integration of AI models with GUI applications.
Performance optimization between CPU vs GPU inference using CUDA.
Importance of data preprocessing and confidence tuning to reduce false positives.
Challenges Faced
Difficulty in finding a reliable and labeled dataset for weapon detection.
Managing false detections — some parts of guns were detected as knives.
Implementing real-time detection without lag.
Ensuring model compatibility with both CPU and GPU environments.
Handling Tkinter multithreading for smooth UI performance.
Future Scope
Integrate violence action detection using CNN/LSTM models.
Enable alert notifications (email/SMS) when weapons are detected.
Deploy system on CCTV networks or IoT cameras for real-world surveillance.