📚 Course contents
AI & Computer Vision, lesson 26 of 52
Object Tracking: Following Players
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
| Step | What happens |
|---|---|
| Predict | For each known player, guess where they are now (they keep moving as they were) |
| Match | Pair predicted boxes with new detections: the best overlaps (IoU) win. The Hungarian algorithm finds the best overall pairing. |
| Update | Matched players get their new position |
| Create | An unmatched detection starts a new track (a new ID) |
| Retire | A 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
| Problem | What you see | Typical cause |
|---|---|---|
| ID switch | Two players swap IDs after crossing | They overlap, and the match picks the wrong one |
| Fragmentation | One player gets 2 or 3 IDs over time | The player was hidden longer than max_missed, so a new track started |
| Ghost tracks | An ID follows nothing, or a referee or a flag | False detections that persist |
| Flicker | IDs appear for a few frames only | Weak detections that never get confirmed |
The settings that matter
| Setting | Too low | Too high |
|---|---|---|
max_missed (patience) | The ID is dropped during short occlusions: fragmentation | Old tracks hang around and can steal new detections |
| IoU threshold for matching | Wrong matches (ID switches) | Fast movers lose their track |
min_hits before a track is "confirmed" | Ghost tracks appear | New 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.

