-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbyte_track_demo.rs
More file actions
44 lines (36 loc) · 1.31 KB
/
Copy pathbyte_track_demo.rs
File metadata and controls
44 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use trackforge::trackers::byte_track::ByteTrack;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize ByteTrack
// track_thresh = 0.5: Threshold for high confidence detections
// track_buffer = 30: Frames to keep lost tracks alive
// match_thresh = 0.8: IoU threshold for matching
// det_thresh = 0.6: Threshold for detection initialization
let mut tracker = ByteTrack::new(0.5, 30, 0.8, 0.6);
// Simulated detection input: [x, y, w, h], score, class_id
let frame_1_detections = vec![
([100.0, 100.0, 50.0, 100.0], 0.9, 0),
([200.0, 200.0, 60.0, 120.0], 0.85, 0),
];
println!("Processing Frame 1...");
let tracks_1 = tracker.update(frame_1_detections);
for t in tracks_1 {
println!(
"Track ID: {}, Box: {:?}, Score: {:.2}",
t.track_id, t.tlwh, t.score
);
}
// Simulated movement for Frame 2
let frame_2_detections = vec![
([105.0, 102.0, 50.0, 100.0], 0.92, 0), // Moved slightly
([202.0, 201.0, 60.0, 120.0], 0.88, 0),
];
println!("\nProcessing Frame 2...");
let tracks_2 = tracker.update(frame_2_detections);
for t in tracks_2 {
println!(
"Track ID: {}, Box: {:?}, Score: {:.2}",
t.track_id, t.tlwh, t.score
);
}
Ok(())
}