๐๐ฅ Real-Time Accident Detection with YOLOv5 & Streamlit A real-time accident detection system using YOLOv5, OpenCV, and Streamlit, enhanced with sound alerts, logging, and live dashboard updates. Designed to detect collisions between vehicles in a video stream and log incidents with frame evidence and timestamps.
๐ Features ๐ YOLOv5 Object Detection Detects vehicles (cars, trucks, buses, bikes) in real-time using YOLOv5s.
๐ผ๏ธ Live Video Feed with Streamlit Displays a real-time webcam stream with frame counter and collision alerts.
๐ฅ Collision Detection Logic Uses bounding box overlap (IoU) to detect accidents based on object proximity.
๐ Frame Capture & Evidence Logging Saves frames of detected accidents in an evidence/ folder with a CSV log.
๐ Real-Time Sound Alerts Plays an alert sound (via pygame) when a crash is detected.
๐ง Tech Stack Tool Purpose YOLOv5 Real-time vehicle detection OpenCV Video stream handling Streamlit Live UI dashboard Pandas Logging accident data to CSV Pygame Playing alert sounds Python Overall integration and logic ๐ฆ Installation
git clone https://github.com/your-username/accident-detection-yolov5 cd accident-detection-yolov5
pip install -r requirements.txt
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install opencv-python streamlit pandas pygame Make sure you have a working webcam and Python 3.8+.
A live camera feed will start.
When an accident is detected, you'll:
Hear a sound
See an alert in the UI
Get a frame saved in /evidence
See logs in logs.csv
๐ Project Structure โโโ app.py # Main Streamlit App โโโ alert.mp3 # Sound file for alert โโโ logs.csv # Logged accident info โโโ evidence/ # Captured frames โโโ requirements.txt # Dependencies ๐ฎ Future Improvements ๐ฆ Accident type classification (rear-end, side collision, etc.)
๐ง Integrate with vehicle tracking and motion estimation
๐ Dashboard with map integration or multiple cameras
๐งฉ Deployable version for Raspberry Pi or Jetson Nano
๐ธ Preview
A live dashboard view with real-time accident detection and alerting.
๐ License This project is licensed under the MIT License.
๐ค Contributing Got ideas or want to improve the logic/model? Pull requests and suggestions are always welcome!