Skip to content

trackforge / trackers / byte_track


Module byte_track

ByteTrack

ByteTrack: Multi-Object Tracking by Associating Every Detection Box

Yifu Zhang, Peize Sun, Yi Jiang, Dongdong Yu, Fucheng Weng, Zehuan Yuan, Ping Luo, Wenyu Liu, Xinggang Wang

arXiv 2110.06864

ByteTrack is a simple, fast and strong multi-object tracker.

Abstract

Multi-object tracking (MOT) aims at estimating bounding boxes and identities of objects in videos. Most methods obtain identities by associating detection boxes whose scores are higher than a threshold. The objects with low detection scores, e.g. occluded objects, are simply thrown away, which brings non-negligible true object missing and fragmented trajectories. To solve this problem, ByteTrack presents a simple, effective and generic association method, tracking by associating every detection box instead of only the high score ones. For the low score detection boxes, it utilizes their similarities with tracklets to recover true objects and filter out the background detections.

Original Repository

This is a clean-room Rust implementation of the ByteTrack algorithm as described in the original paper. The official reference implementation can be found at ifzhang/ByteTrack.

Citation

@article{zhang2022bytetrack,
  title={ByteTrack: Multi-Object Tracking by Associating Every Detection Box},
  author={Zhang, Yifu and Sun, Peize and Jiang, Yi and Yu, Dongdong and Weng, Fucheng and Yuan, Zehuan and Luo, Ping and Liu, Wenyu and Wang, Xinggang},
  booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},
  year={2022}
}

Quick Reference

Item Kind Description
ByteTrack struct ByteTrack tracker implementation.
ByteTrackParams struct Settings for [ByteTrack].
STrack struct A Single Track (STrack) representing a tracked object.
TrackState enum

Types

ByteTrack

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

ByteTrack tracker implementation.

ByteTrack is a simple, fast and strong multi-object tracker.

Example

use trackforge::trackers::byte_track::ByteTrack;

// Initialize tracker
let mut tracker = ByteTrack::new(0.5, 30, 0.8, 0.6);

// 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(track_thresh: f32, track_buffer: usize, match_thresh: f32, det_thresh: f32) -> Self

Create a new ByteTrack instance.

# Arguments

Argument Description
track_thresh Threshold for high confidence detections (e.g., 0.5 or 0.6).
track_buffer Number of frames to keep a lost track alive (e.g., 30).
match_thresh IoU threshold for matching (e.g., 0.8).
det_thresh Threshold for initializing a new track (usually same as or slightly lower than track_thresh).

fn from_params(params: ByteTrackParams) -> Self

Create a ByteTrack tracker from a ByteTrackParams.

ByteTrack activates a track on its first high confidence match, so

params.common.min_hits has no effect here; only common.max_age is used.

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

Update the tracker with detections from the current frame.

# Arguments

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

Returns

  • Vec<STrack> - A list of active tracks in the current frame.

Trait Implementations

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

fn is_in_subset(&self) -> bool

fn to_subset_unchecked(&self) -> SS

fn from_subset(element: &SS) -> SP

impl Tracker for ByteTrack
  • type Track = STrack

fn update(&mut self, detections: Vec<crate::traits::Detection>) -> Vec<STrack>

ByteTrackParams

struct ByteTrackParams {
    pub common: crate::trackers::common::CommonParams,
    pub track_thresh: f32,
    pub match_thresh: f32,
    pub det_thresh: f32,
    pub second_match_thresh: f32,
}

Settings for ByteTrack.

The shared lifecycle fields live in CommonParams; ByteTrack maps its track buffer onto common.max_age. Build it with default, tweak what you need, then pass it to [ByteTrack::from_params].

Fields

Name Type Description
common crate::trackers::common::CommonParams Shared lifecycle settings. common.max_age is how many frames a lost track is kept alive, what ByteTrack calls the track buffer.
track_thresh f32 Score above which a detection is treated as high confidence and matched first. Detections below it are held back for the second, low confidence pass.
match_thresh f32 First stage match cutoff, given as a maximum IoU distance of one minus IoU. A pair matches when its IoU distance is at or below this, so a value of 0.8 means the boxes only need an IoU of 0.2. Lower is stricter.
det_thresh f32 Smallest score an unmatched high confidence detection needs to start a brand new track. Raising it avoids spawning tracks from weak one-off detections.
second_match_thresh f32 Second stage match cutoff for recovering objects from low confidence detections, again a maximum IoU distance. This is ByteTrack's core recovery step, and the reference value is 0.5.

Trait Implementations

impl Clone for ByteTrackParams

fn clone(&self) -> ByteTrackParams

impl Copy for ByteTrackParams
impl Debug for ByteTrackParams

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

impl Default for ByteTrackParams

fn default() -> Self

impl PartialEq for ByteTrackParams

fn eq(&self, other: &ByteTrackParams) -> 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

STrack

struct STrack {
    pub tlwh: [f32; 4],
    pub score: f32,
    pub class_id: i64,
    pub track_id: u64,
    pub state: TrackState,
    pub is_activated: bool,
    pub frame_id: usize,
    pub start_frame: usize,
    pub tracklet_len: usize,
    pub det_ind: Option<usize>,
    // [REDACTED: Private Fields]
}

A Single Track (STrack) representing a tracked object.

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 TrackState Current tracking state (New, Tracked, Lost, Removed).
is_activated bool Whether the track is currently activated (confirmed).
frame_id usize Current frame ID.
start_frame usize Frame ID where the track started.
tracklet_len usize Length of the tracklet (number of frames tracked).
det_ind Option<usize> Index of the source detection in the frame's input list (when available).

Implementations

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

fn activate(&mut self, kf: &KalmanFilter, frame_id: usize, track_id: u64)

fn re_activate(&mut self, new_track: STrack, frame_id: usize, new_track_id: Option<u64>, kf: &KalmanFilter)

fn update(&mut self, new_track: STrack, frame_id: usize, kf: &KalmanFilter)

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

Trait Implementations

impl Clone for STrack

fn clone(&self) -> STrack

impl Debug for STrack

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

TrackState

enum TrackState {
    New,
    Tracked,
    Lost,
    Removed,
}

Trait Implementations

impl Clone for TrackState

fn clone(&self) -> TrackState

impl Copy for TrackState
impl Debug for TrackState

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

impl Eq for TrackState
impl PartialEq for TrackState

fn eq(&self, other: &TrackState) -> 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