Skip to content

trackforge / trackers / deepsort


Module deepsort

DeepSORT (Simple Online and Realtime Tracking with a Deep Association Metric) implementation.

This module provides a DeepSORT tracker that uses appearance features for more robust tracking.

Quick Reference

Item Kind Description
DeepSort struct Deep SORT tracker implementation.

Types

Track

struct Track {
    pub track_id: u64,
    pub class_id: i64,
    pub hits: usize,
    pub age: usize,
    pub time_since_update: usize,
    pub state: TrackState,
    pub mean: crate::utils::kalman::StateVector,
    pub covariance: crate::utils::kalman::CovarianceMatrix,
    pub score: f32,
    pub features: Vec<Vec<f32>>,
    // [REDACTED: Private Fields]
}

Fields

Name Type Description
features Vec<Vec<f32>> Features (embeddings) collected during the current update cycle or while tentative. These are flushed to the metric gallery when appropriate.

Implementations

fn new(mean: StateVector, covariance: CovarianceMatrix, track_id: u64, class_id: i64, n_init: usize, max_age: usize, score: f32, feature: Vec<f32>) -> Self

fn tlwh_to_xyah(tlwh: &[f32; 4]) -> MeasurementVector

Convert TLWH to (x, y, a, h)

fn xyah_to_tlwh(state: &StateVector) -> [f32; 4]

Convert (x, y, a, h) to TLWH

fn to_tlwh(&self) -> [f32; 4]

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

fn update(&mut self, kf: &KalmanFilter, detection: &MeasurementVector, score: f32, class_id: i64, feature: Vec<f32>)

fn mark_missed(&mut self)

fn is_confirmed(&self) -> bool

fn is_tentative(&self) -> bool

fn is_deleted(&self) -> bool

Trait Implementations

impl Clone for Track

fn clone(&self) -> Track

impl Debug for Track

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

DeepSortTracker

struct DeepSortTracker {
    pub metric: crate::trackers::deepsort::nn_matching::NearestNeighborDistanceMetric,
    pub max_age: usize,
    pub n_init: usize,
    pub tracks: Vec<crate::trackers::deepsort::track::Track>,
    pub kf: crate::utils::kalman::KalmanFilter,
    pub max_iou_distance: f32,
}

Implementations

fn new(metric: NearestNeighborDistanceMetric, max_age: usize, n_init: usize, max_iou_distance: f32) -> Self

fn predict(&mut self)

fn update(&mut self, detections: &[(crate::types::BoundingBox, f32, i64)], embeddings: &[Vec<f32>])

fn initiate_track(&mut self, tlwh: &[f32; 4], score: f32, class_id: i64, embedding: Vec<f32>)

Trait Implementations

impl Clone for DeepSortTracker

fn clone(&self) -> DeepSortTracker

impl Debug for DeepSortTracker

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

DeepSort<E: AppearanceExtractor>

struct DeepSort<E: AppearanceExtractor> {
    // [REDACTED: Private Fields]
}

Deep SORT tracker implementation.

Wraps the tracker logic and appearance feature extraction.

Implementations

fn new(extractor: E, max_age: usize, n_init: usize, max_iou_distance: f32, max_cosine_distance: f32, nn_budget: usize) -> Self

Create a new Deep SORT tracker.

# Arguments

Argument Description
extractor The appearance feature extractor.
max_age Maximum frames to keep a track without detection. Default: 70.
n_init Minimum hits to confirm a track. Default: 3.
max_iou_distance Threshold for IoU matching. Default: 0.7.
max_cosine_distance Threshold for cosine distance matching. Default: 0.2.
nn_budget Maximum library size for appearance features. Default: 100.

fn update(&mut self, image: &DynamicImage, detections: Vec<(BoundingBox, f32, i64)>) -> Result<Vec<Track>, Box<dyn Error>>

Update the tracker with new frame and detections.

# Arguments

Argument Description
image The current video frame.
detections List of (BoundingBox, Score, ClassID).

# Returns

List of confirmed tracks.

fn new_default(extractor: E) -> Self

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

Metric

enum Metric {
    Euclidean,
    Cosine,
}

Trait Implementations

impl Clone for Metric

fn clone(&self) -> Metric

impl Copy for Metric
impl Debug for Metric

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

impl Eq for Metric
impl PartialEq for Metric

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

TrackState

enum TrackState {
    Tentative,
    Confirmed,
    Deleted,
}

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