top of page

People Tracking System with Python

Follow our steps! 

STEP 1

Before writing any codes,  first install OpenCV. Go to command prompt and type pip install opencv-contrib-python.

STEP 2

A multi-object tracker is simply a collection of single object trackers. We start by defining a function that takes a tracker type as input and creates a tracker object. OpenCV has 8 different tracker types : BOOSTING, MIL, KCF,TLD, MEDIANFLOW, GOTURN, MOSSE, CSRT.

STEP 3

A multi-object tracker requires two inputs, a video frame and location of all objects we want to track. Based on this information, the tracker tracks the location of these specified objects in all subsequent frames.

STEP 4

Next, we need to locate objects we want to track in the first frame. The location is simply a bounding box.

STEP 5

We first create a MultiTracker object and add as many single object trackers to it as we have bounding boxes. In this example, we use the CSRT single object tracker, but you try other tracker types by changing the trackerType variable 

STEP 6

Finally, our MultiTracker is ready and we can track multiple objects in a new frame. We use the update method of the MultiTracker class to locate the objects in a new frame. Each bounding box for each tracked object is drawn using a different color.

Download the source code and sample video here!

Proudly created by TacoCat

bottom of page