1use std::fmt::Debug;
5
6pub use uuid::Uuid;
7pub mod bytetrack;
8pub use bytetrack::{ByteTrack, ByteTrackBuilder};
9pub mod kalman;
10
11pub trait DetectionBox: Debug + Clone {
12 fn bbox(&self) -> [f32; 4];
13 fn score(&self) -> f32;
14 fn label(&self) -> usize;
15}
16
17#[derive(Debug, Clone, Copy)]
19#[doc(hidden)]
20pub struct MockDetection {
21 bbox: [f32; 4],
22 score: f32,
23 label: usize,
24}
25
26impl MockDetection {
27 pub fn new(bbox: [f32; 4], score: f32, label: usize) -> Self {
29 Self { bbox, score, label }
30 }
31}
32
33impl DetectionBox for MockDetection {
34 fn bbox(&self) -> [f32; 4] {
35 self.bbox
36 }
37
38 fn score(&self) -> f32 {
39 self.score
40 }
41
42 fn label(&self) -> usize {
43 self.label
44 }
45}
46
47#[derive(Debug, Clone, Copy, PartialEq)]
48pub struct TrackInfo {
49 pub uuid: Uuid,
50 pub tracked_location: [f32; 4],
52 pub count: i32,
53 pub created: u64,
54 pub last_updated: u64,
55}
56
57#[derive(Debug, Clone, Copy, PartialEq)]
58pub struct ActiveTrackInfo<T: DetectionBox> {
59 pub info: TrackInfo,
60 pub last_box: T,
63}
64
65pub trait Tracker<T: DetectionBox> {
66 fn update(&mut self, boxes: &[T], timestamp: u64) -> Vec<Option<TrackInfo>>;
67 fn get_active_tracks(&self) -> Vec<ActiveTrackInfo<T>>;
68}