Skip to content

trackforge / trackers / sort


Module sort

SORT: Simple Online and Realtime Tracking

This module implements the SORT (Simple Online and Realtime Tracking) algorithm.

Algorithm Overview

SORT is a simple yet effective multi-object tracking algorithm that combines: - Kalman Filtering for motion prediction - Hungarian Algorithm for data association using IoU (Intersection over Union)

Key Features

  • Real-time performance: Designed for speed with minimal computational overhead
  • No appearance features: Uses only bounding box information
  • Simple track management: Tracks are created, confirmed, and deleted based on hit/miss counts

Parameters

Parameter Default Description
max_age 1 Maximum frames to keep a track without detection
min_hits 3 Minimum consecutive hits before track is confirmed
iou_threshold 0.3 Minimum IoU for matching detection to track

References

Simple Online and Realtime Tracking Alex Bewley, Zongyuan Ge, Lionel Ott, Fabio Ramos, Ben Upcroft IEEE International Conference on Image Processing (ICIP), 2016 arXiv:1602.00763

Quick Reference

Item Kind Description
Sort struct SORT (Simple Online and Realtime Tracking) tracker.
SortTrack struct A single track in SORT.
SortTrackState enum Track state enumeration for SORT.

Types

Sort

struct Sort {
    // [REDACTED: Private Fields]
}

SORT (Simple Online and Realtime Tracking) tracker.

Example

use trackforge::trackers::sort::Sort;

// Initialize tracker
let mut tracker = Sort::new(1, 3, 0.3);

// Simulated detections: (tlwh_box, score, class_id)
let detections = vec![
    ([100.0, 100.0, 50.0, 100.0], 0.9, 0),
    ([200.0, 200.0, 60.0, 120.0], 0.85, 0),
];

// Update tracker
let tracks = tracker.update(detections);

for track in tracks {
    println!("Track ID: {}, Box: {:?}", track.track_id, track.tlwh);
}

Implementations

fn new(max_age: usize, min_hits: usize, iou_threshold: f32) -> Self

Create a new SORT tracker instance.

# Arguments

Argument Description
max_age Maximum frames to keep a track without detection (default: 1).
min_hits Minimum consecutive hits before track is confirmed (default: 3).
iou_threshold Minimum IoU for matching detection to track (default: 0.3).

fn update(&mut self, detections: Vec<([f32; 4], f32, i64)>) -> Vec<SortTrack>

Update the tracker with detections from the current frame.

# Arguments

Argument Description
detections A vector of detections, where each detection is (TLWH_Box, Score, ClassID).

# Returns

A vector of confirmed tracks.

Trait Implementations

impl Default for Sort

fn default() -> Self

impl<R> ReadPrimitive<R> for Sort

fn to_subset(&self) -> Option<SS>

fn is_in_subset(&self) -> bool

fn to_subset_unchecked(&self) -> SS

fn from_subset(element: &SS) -> SP

SortTrack

struct SortTrack {
    pub tlwh: [f32; 4],
    pub score: f32,
    pub class_id: i64,
    pub track_id: u64,
    pub state: SortTrackState,
    pub hits: usize,
    pub time_since_update: usize,
    pub age: usize,
    // [REDACTED: Private Fields]
}

A single track in SORT.

Fields

Name Type Description
tlwh [f32; 4] Bounding box in TLWH (Top-Left-Width-Height) format.
score f32 Detection confidence score.
class_id i64 Class ID of the object.
track_id u64 Unique track ID.
state SortTrackState Current tracking state.
hits usize Number of consecutive hits (matched detections).
time_since_update usize Number of consecutive misses (no matched detection).
age usize Total age of the track in frames.

Implementations

fn new(tlwh: [f32; 4], score: f32, class_id: i64, kf: &KalmanFilter) -> Self

Create a new track from a detection.

fn predict(&mut self, kf: &KalmanFilter)

Predict the next state using Kalman filter.

fn mark_deleted(&mut self)

Mark track as deleted.

fn is_confirmed(&self) -> bool

Check if track should be confirmed based on min_hits.

Trait Implementations

impl Clone for SortTrack

fn clone(&self) -> SortTrack

impl Debug for SortTrack

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result

fn to_subset(&self) -> Option<SS>

fn is_in_subset(&self) -> bool

fn to_subset_unchecked(&self) -> SS

fn from_subset(element: &SS) -> SP

SortTrackState

enum SortTrackState {
    Tentative,
    Confirmed,
    Deleted,
}

Track state enumeration for SORT.

Variants

  • Tentative

Track is tentative (not yet confirmed).

  • Confirmed

Track is confirmed and active.

  • Deleted

Track is deleted.

Trait Implementations

impl Clone for SortTrackState

fn clone(&self) -> SortTrackState

impl Copy for SortTrackState
impl Debug for SortTrackState

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for SortTrackState
impl PartialEq for SortTrackState

fn eq(&self, other: &SortTrackState) -> bool

fn to_subset(&self) -> Option<SS>

fn is_in_subset(&self) -> bool

fn to_subset_unchecked(&self) -> SS

fn from_subset(element: &SS) -> SP