sightloom_tracking/
config.rs1use crate::TrackError;
4
5#[derive(Clone, Copy, Debug, PartialEq)]
7pub struct ByteTrackConfig {
8 pub track_high_thresh: f32,
10 pub track_activation_thresh: f32,
12 pub track_low_thresh: f32,
14 pub match_thresh: f32,
16 pub max_time_lost: u32,
18 pub class_aware: bool,
20}
21
22impl Default for ByteTrackConfig {
23 fn default() -> Self {
24 Self {
25 track_high_thresh: 0.5,
26 track_activation_thresh: 0.6,
27 track_low_thresh: 0.1,
28 match_thresh: 0.8,
29 max_time_lost: 30,
30 class_aware: false,
31 }
32 }
33}
34
35impl ByteTrackConfig {
36 pub fn validate(self) -> Result<Self, TrackError> {
42 let thresholds = [
43 self.track_high_thresh,
44 self.track_activation_thresh,
45 self.track_low_thresh,
46 self.match_thresh,
47 ];
48 for value in thresholds {
49 if !value.is_finite() || !(0.0..=1.0).contains(&value) {
50 return Err(TrackError::InvalidConfig);
51 }
52 }
53 if self.track_low_thresh > self.track_high_thresh {
54 return Err(TrackError::InvalidConfig);
55 }
56 if self.max_time_lost == 0 {
57 return Err(TrackError::InvalidConfig);
58 }
59 Ok(self)
60 }
61}