📚 Course contents

AI & Computer Vision, lesson 26 of 52

Object Tracking: Following Players

intermediate26 min readFull course

Introduction

Your detector finds every player in every frame, but it has no idea who is who: frame by frame it just sees "player, player, player". To measure how far someone ran or where they spent the match, you need each player to keep the same ID. That's tracking, and today you'll build a simple tracker yourself, then use a professional one.

By the end of this lesson you'll be able to:

  • Explain why a detector alone has no memory, and what a tracker adds
  • Describe the tracking cycle: predict, match, update, create, retire
  • Explain how IoU is used to match boxes between frames
  • Say what an ID switch and ID fragmentation are, and measure them
  • Tune max_missed (how long to wait for a lost player)
  • Run ByteTrack through Ultralytics and save every track to a CSV file
  • Read basic track statistics and spot a broken track

Working principle

The problem: detection has no identity

In each frame the detector returns boxes without names. For stats like distance run, heatmaps and passes, we need to know that this box is the same player as the one in the last frame.

The tracking cycle

StepWhat happens
PredictFor each known player, guess where they are now (they keep moving as they were)
MatchPair predicted boxes with new detections: the best overlaps (IoU) win. The Hungarian algorithm finds the best overall pairing.
UpdateMatched players get their new position
CreateAn unmatched detection starts a new track (a new ID)
RetireA player not seen for more than max_missed frames is dropped

The tracker predicts where each player goes and matches boxes by overlap, so #7 stays #7 even when they cross.

This is the heart of SORT. ByteTrack adds a clever twist: it also uses low-confidence detections (the half-hidden players that other trackers throw away) to keep tracks alive through occlusions.

Things that go wrong

ProblemWhat you seeTypical cause
ID switchTwo players swap IDs after crossingThey overlap, and the match picks the wrong one
FragmentationOne player gets 2 or 3 IDs over timeThe player was hidden longer than max_missed, so a new track started
Ghost tracksAn ID follows nothing, or a referee or a flagFalse detections that persist
FlickerIDs appear for a few frames onlyWeak detections that never get confirmed

The settings that matter

SettingToo lowToo high
max_missed (patience)The ID is dropped during short occlusions: fragmentationOld tracks hang around and can steal new detections
IoU threshold for matchingWrong matches (ID switches)Fast movers lose their track
min_hits before a track is "confirmed"Ghost tracks appearNew players take longer to appear

How we judge a tracker without ground truth

A perfect answer needs a human to label every player in every frame, which is expensive. A quick proxy: count the different IDs. If 3 players are on screen for 120 frames and the tracker used 9 IDs, it fragmented. A track-statistics script reports IDs used, how long each lived, and how many players are found per frame.

Object Tracking: Following Players | Electronics Simplified