Vehicle Tracking using Centroid tracker

Algorithm used : Yolo algorithm for detection + centroid tracker to track vehicles

Backend : opencv and python

Library required:

  • opencv = '4.5.4-dev'
  • scipy = '1.4.1'


  • I hadn't uploaded model weights and configuration files (which were used for object detection) here because those were already available in yolo_detection repo
  • download yolo tiny weights , config file and coco.names file from here : []
  • For detection i was using same code which was available in yolo_detection repo.

Quick Overview about structure


  • Loading model and user configurations
  • perform interfacing tasks


  • use opencv modules to detect objects from user given media(photo/video)
  • detection take place inside this file

3) config.json

  • user configuration are mentioned inside this file
  • for examples : input shapes and model parameters(weights file path , config file path etc) are added in config.json


  • implementation of centroid tracker

How to use

clone this directory

use following command to run detection and tracking on your custom video

python -c config.json -v <media_path>


python -c config.json -v car1.mp4
  • Note : Before executing this command make sure that you have downloaded model weights and config file for yolo object detection.





There are two primary drawbacks of this object tracking algorithm.

The first is that it requires that object detection step to be run on every frame of the input video.

The second drawback is related to the underlying assumptions of the centroid tracking algorithm itself — centroids must lie close together between subsequent frames.

If it's helful for you then please give star :)


View Github