Skip to content

trackforge / utils / kalman


Module kalman

Quick Reference

Item Kind Description
KalmanFilter struct A standard Kalman Filter implementation for bounding box tracking.
CovarianceMatrix type 8×8 state covariance matrix.
MeasurementMatrix type 4×8 observation matrix mapping state space to measurement space.
MeasurementVector type 4-D measurement vector [x, y, a, h] (centre-x, centre-y, aspect ratio, height).
StateVector type 8-D Kalman state vector [x, y, a, h, vx, vy, va, vh].

Types

KalmanFilter

struct KalmanFilter {
    // [REDACTED: Private Fields]
}

A standard Kalman Filter implementation for bounding box tracking.

Ref: "Simple Online and Realtime Tracking with a Deep Association Metric" (DeepSORT)

Implementations

fn new(std_weight_position: f32, std_weight_velocity: f32) -> Self

Create a new Kalman Filter instance.

fn initiate(&self, measurement: &MeasurementVector) -> (StateVector, CovarianceMatrix)

Initiate the Kalman Filter state from a measurement.

# Arguments

Argument Description
measurement The initial measurement vector [x, y, a, h].

# Returns

A tuple containing the initial Mean vector and Covariance matrix.

fn predict(&self, mean: &StateVector, covariance: &CovarianceMatrix) -> (StateVector, CovarianceMatrix)

Predict the next state of the Kalman Filter.

# Arguments

Argument Description
mean The current state mean vector.
covariance The current state covariance matrix.

# Returns

A tuple containing the predicted Mean vector and Covariance matrix.

fn update(&self, mean: &StateVector, covariance: &CovarianceMatrix, measurement: &MeasurementVector) -> (StateVector, CovarianceMatrix)

Update the Kalman Filter state with a new measurement.

# Arguments

Argument Description
mean The predicted state mean vector.
covariance The predicted state covariance matrix.
measurement The new measurement vector [x, y, a, h].

# Returns

A tuple containing the updated Mean vector and Covariance matrix.

fn gating_distance(&self, mean: &StateVector, covariance: &CovarianceMatrix, measurements: &[MeasurementVector]) -> Vec<f32>

Calculate the Mahalanobis distance between the track state and each measurement.

Projects the track state into measurement space and computes the squared

Mahalanobis distance using the full [x, y, a, h] measurement vector.

# Arguments

Argument Description
mean The current state mean.
covariance The current state covariance.
measurements Measurements to compare against.

# Returns

A vector of squared Mahalanobis distances, one per measurement.

Trait Implementations

impl Clone for KalmanFilter

fn clone(&self) -> KalmanFilter

impl Debug for KalmanFilter

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Default for KalmanFilter

fn default() -> Self

impl Read<Exclusive, BecauseExclusive> for KalmanFilter
impl<R> ReadPrimitive<R> for KalmanFilter

fn to_subset(&self) -> Option<SS>

fn is_in_subset(&self) -> bool

fn to_subset_unchecked(&self) -> SS

fn from_subset(element: &SS) -> SP

CovarianceMatrix

type CovarianceMatrix = nalgebra::SMatrix<f32, 8, 8>;

8×8 state covariance matrix.

MeasurementMatrix

type MeasurementMatrix = nalgebra::SMatrix<f32, 4, 8>;

4×8 observation matrix mapping state space to measurement space.

MeasurementVector

type MeasurementVector = nalgebra::SVector<f32, 4>;

4-D measurement vector [x, y, a, h] (centre-x, centre-y, aspect ratio, height).

StateVector

type StateVector = nalgebra::SVector<f32, 8>;

8-D Kalman state vector [x, y, a, h, vx, vy, va, vh].