Sub topic 3
Appearance embeddings and re-identification
This chapter assumes you know IoU, the Hungarian algorithm, and constant-velocity Kalman filters.
Appearance embeddings and re-identification
An appearance embedding is a fixed-length vector, often 128 to 512 numbers, that a neural network computes from an image crop of one object. Crops of the same object should produce vectors that point in similar directions. Re-identification (re-ID) uses these vectors to match an object across frames.
Compare two embeddings with cosine similarity:
import numpy as np
def cosine_similarity(a, b):
a = a / np.linalg.norm(a)
b = b / np.linalg.norm(b)
return float(a @ b)
track_emb = np.array([0.9, 0.1, 0.2])
det_emb = np.array([0.8, 0.2, 0.25])
print(round(cosine_similarity(track_emb, det_emb), 3)) # 0.99: likely the same objectDeepSORT: motion plus appearance
DeepSORT extends SORT with a re-ID network. Each track keeps a gallery of recent embeddings. The cost for a track-detection pair combines a Mahalanobis distance from the Kalman prediction (motion) with the cosine distance to the gallery (appearance). A motion gate removes pairs that are physically implausible before the Hungarian step runs.
ByteTrack: recovering low-confidence detections
Detectors often output real but low-score boxes for partly hidden objects. ByteTrack matches high-score detections first. It then matches the unmatched tracks against the low-score boxes using IoU only. This recovers occluded objects, and low-score boxes never start new tracks.
Occlusion, ID switches, and camera motion
An ID switch occurs when a track takes over another object's identity. A fragmentation occurs when one object receives a new ID after a gap. Occlusion causes both. Camera motion breaks Kalman predictions because the whole image shifts, so the motion model must be corrected with global motion estimation.
Evaluating trackers: MOTA, IDF1, and HOTA
| Metric | Emphasizes | Notes |
|---|---|---|
| MOTA | Detection errors and ID switches | Dominated by detection quality |
| IDF1 | Identity consistency over time | Penalizes identity mistakes directly |
| HOTA | Detection, association, and localization | Balances all three |
Benchmarks and datasets
MOTChallenge provides standard sequences such as MOT17 and MOT20, with ground truth and fixed detections. Compare trackers only on the same split and the same detector.
End-to-end and transformer-based trackers
Joint detection and tracking models predict boxes and track associations in one network. Transformer trackers such as TrackFormer and MOTR carry object queries from frame to frame. They reduce hand-tuned rules but need more training data and compute. Tracking-by-detection remains the better choice when you need to swap detectors or inspect each stage.
Exercise
A track's cosine similarity to a new detection is 0.45, and the gallery threshold is 0.7. Should DeepSORT accept this pair on appearance alone?
Show answer
No. A similarity of 0.45 is below the 0.7 threshold, so the appearance check rejects the pair. The track can still match another detection that passes both the motion gate and the appearance threshold.