Skip to content

About

Real-time vehicle detection, multi-object tracking, speed estimation, vehicle counting, and traffic analytics using YOLOv8, SORT, OpenCV, and Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

🚦 Multi-Object Tracking (MOT) and Edge Analytics for Intelligent Traffic Monitoring

A traffic monitoring system that performs vehicle detection, multi-object tracking, vehicle counting, and speed estimation using YOLOv8, SORT Tracker, OpenCV, and cvzone.

The system processes traffic videos, detects multiple vehicles, assigns unique tracking IDs, counts vehicles crossing a predefined line, estimates vehicle speeds, and provides real-time traffic analytics.


🚀 Features

  • Real-time vehicle detection using YOLOv8
  • Multi-object tracking using SORT Algorithm
  • Vehicle counting using line-crossing detection
  • Vehicle speed estimation
  • Real-time traffic analytics dashboard
  • Region of Interest (ROI) detection using masking
  • Unique ID assignment for tracked vehicles
  • Video-based traffic monitoring

🛠️ Technologies Used

Technology Purpose
Python Core implementation
YOLOv8 Object detection
SORT Multi-object tracking
OpenCV Image and video processing
cvzone Visualization and annotations
NumPy Numerical operations

📂 Project Structure

Multi-Object-Tracking-Traffic-Analytics/
│
├── Traffic_Analytics.py     # Main application
├── yolov8l.pt               # YOLOv8 model weights
├── Traffic.mp4              # Input traffic video
├── Mask.png                 # Region of Interest mask
├── sort.py                  # SORT tracker implementation
└── README.md                # Documentation

⚙️ Installation

Install Required Libraries

pip install opencv-python numpy cvzone ultralytics

▶️ How to Run

Make sure the following files are present in the project folder:

  • yolov8l.pt
  • Traffic.mp4
  • Mask.png
  • sort.py

Run the application:

python Traffic_Analytics.py

Press:

q

to close the application.


🧠 Working Description

Vehicle Detection

YOLOv8 detects vehicles from video frames and provides:

  • Bounding boxes
  • Object classes
  • Confidence scores

Detected vehicle categories:

  • Car
  • Truck
  • Bus
  • Motorbike

Multi-Object Tracking

SORT tracker assigns a unique ID to each vehicle and maintains tracking across multiple frames.

It helps in:

  • Following vehicle movement
  • Maintaining object identity
  • Preventing duplicate counting

Vehicle Counting

A predefined counting line is placed on the road.

When a tracked vehicle crosses the line:

  • The vehicle count is increased
  • The unique ID prevents repeated counting

Speed Estimation

Vehicle speed is estimated using:

  • Object movement between frames
  • Time difference between frames
  • Pixel-to-meter conversion scale

Note: Accurate speed calculation requires proper camera calibration.


Edge Analytics Dashboard

The system displays real-time information:

  • Total vehicles counted
  • Average speed
  • Active vehicle tracks
  • Vehicle ID
  • Vehicle class
  • Confidence score
  • Estimated speed

⚙️ Configuration

Video Source

cap = cv2.VideoCapture("Traffic.mp4")

Replace the video file path or use:

cv2.VideoCapture(0)

for camera input.


Detection Model

model = YOLO("yolov8l.pt")

Available YOLOv8 models:

  • yolov8n.pt → Faster processing
  • yolov8s.pt
  • yolov8m.pt
  • yolov8l.pt → Better accuracy

Vehicle Classes

Currently configured classes:

["car", "truck", "bus", "motorbike"]

Counting Line

limits = [100,400,1200,400]

Format:

[x1, y1, x2, y2]

Coordinates can be adjusted according to the camera view.


Speed Calibration

PIXEL_PER_METER = 15.0

This value controls the conversion between pixel movement and estimated real-world speed.


📈 Future Improvements

  • Improved speed calibration
  • Number plate recognition
  • Traffic violation detection
  • Accident detection
  • Vehicle type classification
  • Live CCTV integration
  • Advanced traffic reporting system

📌 Applications

  • Traffic flow monitoring
  • Road surveillance
  • Vehicle counting systems
  • Smart transportation systems
  • CCTV-based traffic analysis

👩‍💻 Author

Rida Irfan Artificial Intelligence Student


🙌 Credits

  • Ultralytics YOLOv8
  • SORT (Simple Online and Realtime Tracking)
  • OpenCV
  • cvzone

📄 License

This project is developed for educational and research purposes.

About

Real-time vehicle detection, multi-object tracking, speed estimation, vehicle counting, and traffic analytics using YOLOv8, SORT, OpenCV, and Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages