Single Object Tracking and Multi-Object Tracking
Module: Computer Vision | Difficulty: Premium
Siamese Tracker
where is template, is search region.
IoU-Based Association
Track Lifecycle
| Model | GOT-10K | LaSOT | TrackingNet | Speed | |-------|---------|-------|-------------|-------| | SiamRPN++ | 69.6 | 71.3 | 81.8 | 35 fps | | TransT | 73.2 | 76.2 | 85.1 | 25 fps | | OSTrack | 77.8 | 80.1 | 87.5 | 40 fps | | GrMOT | 78.5 | 81.3 | 88.2 | 30 fps | | TLD | 54.2 | 51.1 | 66.2 | 30 fps |
import torch
import torch.nn as nn
import torch.nn.functional as F
class SiameseTracker(nn.Module):
def __init__(self, backbone, head):
super().__init__()
self.backbone = backbone
self.head = head
def extract_template(self, template_img):
with torch.no_grad():
self.template_feat = self.backbone(template_img)
def track(self, search_img):
search_feat = self.backbone(search_img)
return self.head(self.template_feat, search_feat)
class MultiObjectTracker:
def __init__(self, detector, max_age=30, min_hits=3,
iou_threshold=0.3):
self.detector = detector
self.max_age = max_age
self.min_hits = min_hits
self.iou_threshold = iou_threshold
self.tracks = []
self.next_id = 0
def update(self, frame):
detections = self.detector(frame)
if len(self.tracks) == 0:
for det in detections:
self.tracks.append(
{'id': self.next_id, 'bbox': det,
'age': 0, 'hits': 1})
self.next_id += 1
else:
iou_matrix = self._compute_iou(
[t['bbox'] for t in self.tracks], detections)
matched, unmatched_dets, unmatched_trks = self._hungarian_match(iou_matrix)
for t_idx, d_idx in matched:
self.tracks[t_idx]['bbox'] = detections[d_idx]
self.tracks[t_idx]['age'] = 0
self.tracks[t_idx]['hits'] += 1
for t_idx in unmatched_trks:
self.tracks[t_idx]['age'] += 1
for d_idx in unmatched_dets:
self.tracks.append(
{'id': self.next_id, 'bbox': detections[d_idx],
'age': 0, 'hits': 1})
self.next_id += 1
self.tracks = [
t for t in self.tracks if t['age'] < self.max_age]
return [t for t in self.tracks
if t['hits'] >= self.min_hits]
def _compute_iou(self, boxes1, boxes2):
iou = torch.zeros(len(boxes1), len(boxes2))
for i, b1 in enumerate(boxes1):
for j, b2 in enumerate(boxes2):
inter = self._intersection(b1, b2)
union = self._area(b1) + self._area(b2) - inter
iou[i, j] = inter / (union + 1e-6)
return iou
Research Insight: Visual tracking has been transformed by transformer-based architectures (TransT, OSTrack) that replace correlation-based matching with attention mechanisms. The key advantage is global feature interaction between template and search regions, enabling better handling of appearance changes. ByteTrack demonstrated that simple association (keeping all detections, matching by IoU) outperforms complex ReID-based methods for multi-object tracking. The trend is toward foundation models for tracking (e.g., SAM-based trackers) that generalize across object categories without category-specific training.