Skip to content

trackforge / traits


Module traits

Quick Reference

Item Kind Description
AppearanceExtractor trait Trait for extracting appearance features (embeddings) from images.
Tracker trait Common interface for the detection-only trackers.
Detection type A detection passed to a tracker: (tlwh, score, class_id).

Types

Detection

type Detection = ([f32; 4], f32, i64);

A detection passed to a tracker: (tlwh, score, class_id).

The box is in TLWH (top-left x, top-left y, width, height) format.


Traits

AppearanceExtractor

trait AppearanceExtractor { ... }

Trait for extracting appearance features (embeddings) from images.

This allows decoupling the tracker logic (DeepSORT) from the model execution (ONNX, PyTorch via Python, etc.).

Required Methods

  • fn extract(&mut self, image: &DynamicImage, bboxes: &[BoundingBox]) -> Result<Vec<Vec<f32>>, Box<dyn Error>>

Extract features for a list of bounding boxes from a given image.

Tracker

trait Tracker { ... }

Common interface for the detection-only trackers.

SORT, ByteTrack, and OC-SORT all consume a frame's detections and return the active tracks, so generic code can drive any of them through this trait. DeepSORT needs the source frame to extract appearance features and therefore keeps its own update(&image, detections) method instead of this trait.

use trackforge::traits::{Detection, Tracker};
use trackforge::trackers::sort::Sort;

fn run_one<T: Tracker>(tracker: &mut T, dets: Vec<Detection>) -> Vec<T::Track> {
    tracker.update(dets)
}

let mut tracker = Sort::new(1, 1, 0.3);
let tracks = run_one(&mut tracker, vec![([0.0, 0.0, 10.0, 10.0], 0.9, 0)]);
assert_eq!(tracks.len(), 1);

Associated Types

  • type Track

Required Methods

  • fn update(&mut self, detections: Vec<Detection>) -> Vec<<Self as >::Track>

Update the tracker with the current frame's detections and return the

Implementors