Skip to main content

DetectionBox

Trait DetectionBox 

Source
pub trait DetectionBox: Debug + Clone {
    // Required methods
    fn bbox(&self) -> [f32; 4];
    fn score(&self) -> f32;
    fn label(&self) -> usize;
}
Expand description

A bounding box produced by a detection model, suitable for use with a Tracker.

Implement this trait on your model’s output type to feed it directly into ByteTrack without copying. The tracker crate has no dependency on edgefirst-decoder; any type that can report an XYXY box, a confidence score, and a class label satisfies this contract.

§Coordinates

bbox() must return [xmin, ymin, xmax, ymax] in normalised [0, 1] coordinates or in pixel coordinates — the tracker does not prescribe units, but all detections passed to a single Tracker::update call must use the same coordinate space.

§Example

use edgefirst_tracker::DetectionBox;

#[derive(Debug, Clone)]
struct MyDetection { bbox: [f32; 4], score: f32, label: usize }

impl DetectionBox for MyDetection {
    fn bbox(&self)  -> [f32; 4] { self.bbox }
    fn score(&self) -> f32      { self.score }
    fn label(&self) -> usize    { self.label }
}

Required Methods§

Source

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

Bounding box in [xmin, ymin, xmax, ymax] (XYXY) format.

Source

fn score(&self) -> f32

Confidence score in [0, 1]. Used by ByteTrack to separate high-confidence detections (first-pass matching) from low-confidence ones (second-pass matching).

Source

fn label(&self) -> usize

Class index (0-based). Stored in the tracklet for callers that need per-class track metadata; the tracker itself does not gate matching on label — a tracklet may receive detections from different classes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§