Sub topic 13
Evaluating trackers: MOTA, IDF1, and HOTA
This chapter assumes you know how a tracking-by-detection pipeline produces track IDs per frame (earlier chapters), can read basic NumPy, and understand IoU and the Hungarian algorithm. It covers three questions. What does each metric count? What does each one hide? How do you pick the right one for a system?
Why tracking needs its own metrics
A detector is scored on whether boxes appear in the right places. A tracker also has to keep the same ID on the same object across time. Two trackers can draw identical boxes in every frame, yet one swaps the IDs of two crossing people and the other doesn't. A detection metric such as mAP cannot tell them apart.
Tracking metrics therefore need two things:
- A rule for matching predicted boxes to ground-truth boxes (usually IoU of at least 0.5).
- A rule for penalizing identity errors over time.
The three metrics in this chapter differ mainly in the second rule.
The raw counts
All three metrics start from the same bookkeeping. In each frame, match predictions to ground truth with the Hungarian algorithm, then count:
- TP (true positive): a prediction matched to a ground-truth box.
- FN (false negative): a ground-truth box with no matched prediction, also called a miss.
- FP (false positive): a prediction with no matched ground-truth box.
- IDSW (identity switch): a ground-truth object whose matched prediction ID differs from the ID it was last matched to.
Fragmentation (Frag) counts how often a ground-truth trajectory is interrupted and later resumed. It is reported next to the main metrics. Mostly tracked (MT) and mostly lost (ML) report the fraction of ground-truth trajectories covered for at least 80% or at most 20% of their lifetime.
MOTA: counting errors
MOTA (Multiple Object Tracking Accuracy) is part of the CLEAR MOT metric family. It is one minus the total error rate:
MOTA = 1 - (FN + FP + IDSW) / GTHere GT is the total number of ground-truth boxes over all frames. A perfect tracker scores 1. Because the errors can exceed GT, MOTA can go negative.
What MOTA tells you:
- It is easy to compute and easy to explain.
- It is a good summary of how well the tracker finds objects.
What it hides:
- Detection dominates. On typical benchmarks, FN and FP outnumber ID switches by a large factor. A tracker with a better detector can gain MOTA while its identity handling stays the same or gets worse.
- Each switch costs one unit. A switch that happens once and is never corrected costs the same as a switch that is corrected on the next frame. MOTA does not ask how long the right ID survived.
- The weights are fixed. Treating a miss, a false alarm, and a switch as equally bad is a design choice, not a law.
IDF1: scoring identities over whole trajectories
IDF1 (identity F1 score) asks a different question: how much of the time does each object carry a single, consistent predicted ID?
Instead of matching frame by frame, IDF1 computes one global matching between ground-truth trajectories and predicted trajectories. Each ground-truth identity is paired with at most one predicted ID, chosen to maximize the number of frames in which the two agree. Then:
- IDTP: boxes covered by a matched identity pair.
- IDFN: ground-truth boxes not covered by their paired ID.
- IDFP: predicted boxes not covered by their paired ground-truth identity.
IDF1 = 2 * IDTP / (2 * IDTP + IDFP + IDFN)This is an F1 score over identities. If a person is tracked as ID 4 for 90 frames and ID 7 for 10 frames, IDF1 credits only the better ID (90 frames) and treats the other 10 frames as errors. A switch in the middle of a long trajectory costs far more than a switch near the end. IDF1 does not separate detection quality from association quality, so a low score can come from either.
HOTA: balancing detection and association
HOTA (Higher Order Tracking Accuracy) was designed so that detection and association count equally. For one localization threshold α (an IoU value), it is:
HOTA_α = sqrt(DetA_α * AssA_α)- DetA is
TP / (TP + FN + FP). It measures detection quality. - AssA is the average, over all TPs, of
TPA / (TPA + FNA + FPA). For a TP that pairs ground-truth ID g with predicted ID p, TPA is the number of TPs sharing that pair. FNA is the number of g's boxes not matched to p. FPA is the number of p's boxes not matched to g. AssA measures how consistent the association is.
The final HOTA averages HOTA_α over α from 0.05 to 0.95. This also rewards precise boxes, because a tracker with sloppy localization loses score at high α. The final score also splits into a detection component (DetA), an association component (AssA), and a localization component (LocA), so you can see where the tracker is weak.
The diagram shows how the three metrics are built from the same matched output.
Computing the metrics yourself
The script below uses a toy sequence with two ground-truth objects, A and B, over five frames. The tracker gives A the ID 1 throughout. B gets ID 2, is then missed once, and comes back as ID 3. ID 9 is a false alarm in the last two frames. The per-frame matching is already done, so the script focuses on the metric formulas. It computes HOTA at a single α only.
import numpy as np
from collections import Counter
from scipy.optimize import linear_sum_assignment
# Each frame lists matched (gt_id, pred_id) pairs, missed gt ids, and unmatched predicted ids.
frames = [
{"matches": [("A", 1), ("B", 2)], "missed": [], "extra": []},
{"matches": [("A", 1), ("B", 2)], "missed": [], "extra": []},
{"matches": [("A", 1)], "missed": ["B"], "extra": []},
{"matches": [("A", 1), ("B", 3)], "missed": [], "extra": [9]},
{"matches": [("A", 1), ("B", 3)], "missed": [], "extra": [9]},
]
def evaluate(frames):
gt_len, pred_len, pair = Counter(), Counter(), Counter()
last, fn, fp, idsw, tp = {}, 0, 0, 0, 0
for f in frames:
for g, p in f["matches"]:
gt_len[g] += 1
pred_len[p] += 1
pair[(g, p)] += 1
tp += 1
if g in last and last[g] != p:
idsw += 1
last[g] = p
for g in f["missed"]:
gt_len[g] += 1
fn += 1
for p in f["extra"]:
pred_len[p] += 1
fp += 1
gt_total = sum(gt_len.values())
mota = 1 - (fn + fp + idsw) / gt_total
# IDF1: one global one-to-one assignment of gt identities to predicted identities.
gt_ids, pr_ids = sorted(gt_len), sorted(pred_len, key=str)
m = np.zeros((len(gt_ids), len(pr_ids)))
for (g, p), c in pair.items():
m[gt_ids.index(g), pr_ids.index(p)] = c
rows, cols = linear_sum_assignment(-m) # maximise agreeing frames
idtp = m[rows, cols].sum()
idfn = gt_total - idtp
idfp = sum(pred_len.values()) - idtp
idf1 = 2 * idtp / (2 * idtp + idfp + idfn)
# HOTA at one alpha: sqrt(DetA * AssA).
deta = tp / (tp + fn + fp)
assa = sum(c * c / (gt_len[g] + pred_len[p] - c) for (g, p), c in pair.items()) / tp
hota = float(np.sqrt(deta * assa))
return {"FN": fn, "FP": fp, "IDSW": idsw, "MOTA": mota, "IDF1": idf1,
"DetA": deta, "AssA": assa, "HOTA": hota}
for name, value in evaluate(frames).items():
print(f"{name}: {value:.3f}" if isinstance(value, float) else f"{name}: {value}")Running it gives FN 1, FP 2, IDSW 1, MOTA 0.600, IDF1 0.667, DetA 0.750, AssA 0.733, and HOTA 0.742. The expression c * c / (...) is the sum over TPs of TPA / (TPA + FNA + FPA). Each pair contributes c TPs, each scoring c / (gt_len + pred_len - c).
Choosing a metric
| Metric | Main question | Strength | Weakness |
|---|---|---|---|
| MOTA | How many errors in total? | Simple, widely reported | Dominated by detection; one switch costs one unit |
| IDF1 | How consistently is each identity kept? | Rewards long, stable IDs | Mixes detection and association errors |
| HOTA | Are detection and association both good? | Balanced, decomposable, rewards localization | More complex; needs sweeping α |
A practical rule:
- Use MOTA when comparing detectors inside the same tracker.
- Use IDF1 when the product depends on following a single object for a long time, such as counting unique visitors or following one person through a store.
- Use HOTA when you want one headline number and the breakdown into DetA, AssA, and LocA to find what to fix.
- Report IDSW and Frag alongside any of them, because the totals say nothing about where the errors occurred.
Common mistakes
- Comparing across datasets. The scores depend on detection difficulty and density, so a MOTA of 0.7 on one set and 0.7 on another are not equal results.
- Mixing detectors. If two trackers use different detectors, any metric gap may come from the detector. Compare trackers using the same detections.
- Ignoring the matching rule. IoU threshold, handling of ignored regions, and treatment of distractor classes all change scores.
- Forgetting confidence thresholds. Low-confidence boxes add FPs, and dropping them adds FNs. Tune this threshold on a validation split, not on test data.
Exercise
A sequence has 200 ground-truth boxes. A tracker produces 12 misses, 8 false positives, and 5 identity switches. What is its MOTA? Then say why a second tracker with the same MOTA could have a much lower IDF1.
Show answer
MOTA = 1 - (12 + 8 + 5) / 200 = 1 - 25/200 = 0.875. A second tracker could reach the same count with fewer switches but with an ID change in the middle of long trajectories (for example, one switch at the halfway point of every long track). MOTA charges one unit per switch regardless of when it happens. IDF1 credits only the better ID of each trajectory, so it would lose about half of the identity agreement and score much lower.
Exercise
In the toy script, change the frames so B is tracked as ID 2 in frames 0 and 1, then missed in frame 2, then tracked as ID 2 again in frames 3 and 4, and remove the false alarms. What happens to IDSW, MOTA, and IDF1, and why?
Show answer
IDSW stays 0, because B's matched ID never changes after it returns. FN is 1 and FP is 0, so MOTA = 1 - 1/10 = 0.9. For IDF1, IDTP = 5 + 4 = 9, IDFN = 1, and IDFP = 0, so IDF1 = 18/19, about 0.947. A gap in tracking costs a miss but not an identity error when the same ID resumes.