Real-time vehicle detection and tracking using OpenCV and Computer Vision
This project demonstrates a real-time highway vehicle detection and tracking system using Computer Vision techniques.
The application processes highway video footage, detects moving vehicles using background subtraction, extracts the Region of Interest (ROI), and tracks every detected vehicle with a unique ID using the Euclidean Distance Tracking Algorithm.
This project showcases practical applications of Computer Vision in Intelligent Traffic Monitoring Systems (ITS).
- 🎥 Reads highway video
- 🚗 Detects moving vehicles
- 🎯 Region of Interest (ROI) extraction
- 📦 Draws bounding boxes around vehicles
- 🆔 Assigns unique IDs to each vehicle
- ⚡ Real-time multi-object tracking
- 🖥️ Live visualization
- 📊 Background subtraction using MOG2
| Technology | Purpose |
|---|---|
| Python | Programming Language |
| OpenCV | Image Processing |
| NumPy | Numerical Operations |
| Background Subtractor MOG2 | Vehicle Detection |
| Euclidean Distance Tracker | Vehicle Tracking |
Highway-Vehicle-Tracking-System/
│
├── assets/
│ ├── input.gif
│ ├── output.gif
│ ├── screenshot1.png
│ └── screenshot2.png
│
├── src/
│ ├── main.py
│ ├── tracker.py
│ └── white_mask.py
│
├── videos/
│ ├── highway.mp4
│ └── output.mp4
│
├── requirements.txt
├── README.md
├── LICENSE
└── .gitignore
Clone the repository
git clone https://github.com/yourusername/Highway-Vehicle-Tracking-System.gitMove into the project
cd Highway-Vehicle-Tracking-SystemInstall dependencies
pip install opencv-python numpyUpdate the video path inside the script.
video_path = "videos/highway.mp4"Run
python src/main.pyPress ESC to exit.
The system reads highway footage frame-by-frame.
⬇️
Only the road region is processed, reducing unnecessary computations.
⬇️
MOG2 removes the static background and extracts moving vehicles.
⬇️
Noise is removed and binary masks are generated.
⬇️
Contours identify individual vehicle candidates.
⬇️
The Euclidean Distance Tracker assigns a unique ID to every detected vehicle and tracks its movement across frames.
⬇️
Bounding boxes and IDs are drawn in real time.
- 🚦 Intelligent Traffic Monitoring
- 🚓 Smart City Surveillance
- 🚗 Vehicle Analytics
- 🚧 Highway Monitoring
- 🚘 Traffic Flow Analysis
- 🚨 Traffic Violation Detection
🅿️ Parking Management- 🚖 Autonomous Driving Research
- YOLOv8 Vehicle Detection
- DeepSORT Tracking
- Vehicle Counting
- Vehicle Speed Estimation
- Lane Detection
- Traffic Density Analysis
- Vehicle Classification
- Number Plate Recognition (ANPR)
- Streamlit Dashboard
- Real-time Webcam Support
- Computer Vision
- Object Detection
- Multi-Object Tracking
- Background Subtraction
- OpenCV
- Python
- ROI Processing
- Image Thresholding
- Contour Detection
Contributions are welcome!
Feel free to fork this repository, improve the project, and submit a pull request.
If you found this project useful, consider giving it a Star ⭐.
It helps others discover the project and supports my learning journey in Computer Vision and Artificial Intelligence.

