A real-time vehicle speed detection system built using Python, OpenCV, and Ultralytics YOLOv8. The application detects and tracks vehicles in a video stream, measures their speed between predefined reference lines, and displays the calculated speed in real time.
- 🚘 Real-time vehicle detection using YOLOv8
- 🎯 Multi-object tracking with unique IDs
- ⚡ Speed estimation in km/h
- 📹 Supports video files and RTSP/IP camera streams
- 📊 Bounding boxes with vehicle ID and speed
- 🛣️ Configurable detection lines/regions
- 🐍 Simple Python implementation
- Python 3.12
- OpenCV
- Ultralytics YOLOv8
- Nextjs
Speed-Detection/
│
├── backend/
│ ├── main.py
│ ├── speed_detection.py
│ ├── orientation.py
│ └── ...
│
├── frontend (Nextjs)
├── README.md
└── .gitignore
Screenshots and demo videos are available inside the samples/ folder.
samples/
Download and install Python 3.12 from:
https://www.python.org/downloads/
During installation, make sure to enable:
✔ Add Python to PATH
git clone https://github.com/Mavis47/Speed-Detection.git
cd Speed-DetectionWindows
python -m venv venv
venv\Scripts\activateLinux/macOS
python3 -m venv venv
source venv/bin/activatepip install opencv-python
pip install ultralytics
or install everything together
pip install -r requirements.txtpython backend/main.py- Python 3.12
- OpenCV
- Ultralytics
The system supports
- MP4 Videos
- AVI Videos
- RTSP Streams
- IP Cameras
The application displays
- Vehicle Detection
- Vehicle Tracking ID
- Estimated Vehicle Speed (km/h)
- Bounding Boxes
- Detection Lines
Example screenshots and videos can be found in
samples
Contributions are welcome.
- Fork the repository
- Create a new branch
- Commit your changes
- Open a Pull Request
If you found this project useful, consider giving it a ⭐ on GitHub.