This project uses YOLOv8, Streamlit, and OpenCV to automatically detect helmets in video feeds. It allows users to either use a webcam or upload a video for real-time helmet detection. The system is designed to improve safety monitoring by identifying whether individuals are wearing helmets, making it useful for traffic monitoring, construction sites, and other safety-critical environments.
Ensuring safety in various industries, especially in construction and transportation, is of utmost importance. One of the key safety measures is the use of helmets to protect individuals from head injuries. However, manually verifying helmet usage can be time-consuming and prone to errors. This project addresses this challenge by using YOLOv8, a powerful object detection model, along with Streamlit for an easy-to-use interface and OpenCV for video processing. The system automatically detects whether a person is wearing a helmet in real-time through webcam feeds or uploaded video files. This solution can be applied in diverse scenarios such as traffic monitoring, construction site safety, and security surveillance, offering a more efficient way to enforce safety protocols.
The project follows a step-by-step approach to implement helmet detection using computer vision techniques:
Data Collection: The model is trained to detect helmets using a custom dataset, which includes images of individuals wearing helmets in various environments like construction sites and roadways. This dataset is used to fine-tune the YOLOv8 model for optimal helmet detection.
Model Training: The YOLOv8 (You Only Look Once) model is used for object detection. YOLOv8 is a state-of-the-art deep learning model known for its speed and accuracy in real-time object detection. The model is trained to recognize helmets by using labeled data, which helps it learn to differentiate between helmeted and non-helmeted individuals.
Streamlit Interface: The project uses Streamlit, a Python library for creating web applications, to provide an interactive user interface. Through the Streamlit app, users can select either their webcam feed or upload a video file for helmet detection.
Video Processing with OpenCV: OpenCV (Open Source Computer Vision Library) is used to handle video feeds, whether from a webcam or uploaded files. It processes the video frame by frame, passing each frame to the YOLOv8 model for helmet detection.
Real-time Detection: The app provides real-time feedback, detecting helmets in each video frame. The confidence level for each detection can be adjusted using a slider, allowing users to control the detection sensitivity. The system provides an option to stop the detection process at any time.
Post-processing and Display: The detected helmets are highlighted in the video with bounding boxes, providing a clear visual indication of the detected objects. This allows users to easily verify helmet usage in real-time or in uploaded videos.
Python , YOLOv8, Streamlit, OpenCV.
The model was tested using two input options:
Webcam detection – Real-time helmet detection.
Video upload – Processing of pre-recorded videos.
2. Testing Procedure
Confidence Threshold: Adjusted between 0.3 and 0.9.
Test Scenarios:
Webcam mode: Detect helmets in live feed.
Video mode: Upload and process video files.
3. Evaluation Metrics
Precision: Measures the accuracy of detected helmets.
Recall: Measures the ability to detect all actual helmets.
Inference Time: Time taken for processing each frame (important for real-time detection).
The YOLOv8 model performed well under good conditions (high precision and recall). However, performance slightly decreased in less Training epochs or crowded environments. The system was capable of real-time detection.
There are no datasets linked
There are no datasets linked