pub mod feature_tracker;
pub mod kalman;
pub mod object_tracker;
pub mod optical_flow;
pub mod csrt;
pub mod kcf;
pub mod medianflow;
pub mod mosse;
pub mod tld;
pub mod centroid;
pub mod iou_tracker;
pub mod optical_flow_tracker;
pub mod sort;
pub mod sort_enhanced;
pub mod assignment;
pub use feature_tracker::{FeatureTracker, TrackedFeature};
pub use kalman::KalmanFilter;
pub use object_tracker::{ObjectTracker, TrackerType};
pub use optical_flow::{
compute_lk_bouguet_sparse, FlowField, FlowMethod, LkConfig, LkFlowPoint, OpticalFlow,
};
pub use csrt::CsrtTracker;
pub use kcf::KcfTracker;
pub use medianflow::MedianFlowTracker;
pub use mosse::MosseTracker;
pub use tld::TldTracker;
pub use centroid::CentroidTracker;
pub use iou_tracker::{IouTracker, IouTrackerAdvanced};
pub use optical_flow_tracker::{FlowPoint, GrayFrame, LkTracker};
pub use sort::{DeepSortTracker, SortTracker};
pub use sort_enhanced::{BBox as SortBBox, KalmanTrack, SortTrackerV2, TrackedObject};
pub use assignment::{compute_iou, create_iou_cost_matrix, greedy_assignment, hungarian_algorithm};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Point2D {
pub x: f32,
pub y: f32,
}
impl Point2D {
#[must_use]
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
#[must_use]
pub fn distance(&self, other: &Self) -> f32 {
let dx = self.x - other.x;
let dy = self.y - other.y;
(dx * dx + dy * dy).sqrt()
}
#[must_use]
pub fn distance_squared(&self, other: &Self) -> f32 {
let dx = self.x - other.x;
let dy = self.y - other.y;
dx * dx + dy * dy
}
#[must_use]
pub fn dot(&self, other: &Self) -> f32 {
self.x * other.x + self.y * other.y
}
}
impl Default for Point2D {
fn default() -> Self {
Self::new(0.0, 0.0)
}
}
impl From<(f32, f32)> for Point2D {
fn from((x, y): (f32, f32)) -> Self {
Self::new(x, y)
}
}
impl From<Point2D> for (f32, f32) {
fn from(p: Point2D) -> Self {
(p.x, p.y)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TrackQuality {
pub confidence: f64,
pub psr: f64,
pub fb_error: f64,
pub num_features: usize,
}
impl TrackQuality {
#[must_use]
pub const fn new(confidence: f64) -> Self {
Self {
confidence,
psr: 0.0,
fb_error: 0.0,
num_features: 0,
}
}
#[must_use]
pub const fn is_good(&self) -> bool {
self.confidence > 0.7
}
#[must_use]
pub const fn has_failed(&self) -> bool {
self.confidence < 0.3
}
}
impl Default for TrackQuality {
fn default() -> Self {
Self::new(1.0)
}
}