pub struct ConstantVelocityXYAHModel2<R>{
pub mean: SVector<R, 8>,
pub std_weight_position: R,
pub std_weight_velocity: R,
pub update_factor: R,
pub covariance: OMatrix<R, U8, U8>,
/* private fields */
}Expand description
Constant-velocity Kalman filter for tracking a bounding box in XYAH space.
The state vector is [x, y, a, h, ẋ, ẏ, ȧ, ḣ] (8 dimensions):
| Component | Meaning |
|---|---|
x | Centre x coordinate |
y | Centre y coordinate |
a | Aspect ratio (width / height), kept > 0 by a small epsilon floor |
h | Height |
ẋ, ẏ, ȧ, ḣ | First derivatives of the position components |
Measurements arriving via update are in 4-dimensional
XYAH space (no velocity), projected from the 8-D state by the observation
matrix H. The filter uses a scale-adaptive process-noise covariance:
noise magnitude scales proportionally with the box height h, so
fast-moving large objects tolerate wider uncertainty than small static ones.
This is the same Kalman filter parameterisation used in the original ByteTrack paper (Zhang et al., 2022).
Fields§
§mean: SVector<R, 8>Current state estimate: [x, y, a, h, ẋ, ẏ, ȧ, ḣ].
std_weight_position: RScale factor for position noise (1/20 by default). Process noise for
position components is std_weight_position * h.
std_weight_velocity: RScale factor for velocity noise (1/160 by default). Process noise for
velocity components is std_weight_velocity * h.
update_factor: RMeasurement-to-innovation scaling applied in update.
Set via ByteTrackBuilder::track_update.
Values in (0, 1]; lower → smoother (trusts prediction more).
covariance: OMatrix<R, U8, U8>Implementations§
Source§impl<R> ConstantVelocityXYAHModel2<R>
impl<R> ConstantVelocityXYAHModel2<R>
Sourcepub fn new(measurement: &[R; 4], update_factor: R) -> Self
pub fn new(measurement: &[R; 4], update_factor: R) -> Self
Initialise the filter from the first observation.
measurement is [x, y, a, h] in XYAH space. Velocity components are
initialised to zero. The initial covariance is set proportionally to
the box height so larger boxes start with wider uncertainty.
update_factor is stored and applied as a measurement gain in
update.
Sourcepub fn predict(&mut self)
pub fn predict(&mut self)
Advance the filter by one time step with no measurement.
Applies the constant-velocity motion model (mean' = F * mean,
cov' = F * cov * Fᵀ + Q) using a scale-adaptive process-noise
covariance Q proportional to the current box height. Called once
per frame for every active tracklet before the assignment step.
Sourcepub fn project(&self) -> (OMatrix<R, U4, U1>, OMatrix<R, U4, U4>)
pub fn project(&self) -> (OMatrix<R, U4, U1>, OMatrix<R, U4, U4>)
Project the 8-D state into 4-D measurement space.
Returns (projected_mean, projected_covariance) — the expected
measurement and its uncertainty under the current state estimate.
Used by update and by
gating_distance.
Sourcepub fn update(&mut self, measurement: &[R; 4])
pub fn update(&mut self, measurement: &[R; 4])
Correct the state estimate with a new measurement.
measurement is [x, y, a, h] in XYAH space, as produced by
xyxy_to_xyah in the ByteTrack update loop.
The Kalman gain is computed via Cholesky decomposition of the projected covariance. If the decomposition fails (degenerate covariance) the update is silently skipped and the prior state is preserved.
The innovation is scaled by self.update_factor before being applied,
which effectively attenuates the correction — lower values produce
smoother trajectories at the cost of slower response to abrupt motion.
Sourcepub fn gating_distance(
&self,
measurements: &OMatrix<R, Dyn, U4>,
only_position: bool,
metric: GatingDistanceMetric,
) -> DVector<R>
pub fn gating_distance( &self, measurements: &OMatrix<R, Dyn, U4>, only_position: bool, metric: GatingDistanceMetric, ) -> DVector<R>
Compute per-measurement gating distances from the current state.
Returns a vector of one scalar per row in measurements. Each scalar
is either the squared Euclidean distance (GatingDistanceMetric::Gaussian)
or the Mahalanobis distance (GatingDistanceMetric::Mahalanobis) from
the projected state mean to that measurement.
only_position restricts the comparison to the first two components
(x, y), ignoring aspect and height.
Not used by the current ByteTrack integration (which gates via IoU); exposed for future association strategies.
Trait Implementations§
Source§impl<R> Clone for ConstantVelocityXYAHModel2<R>
impl<R> Clone for ConstantVelocityXYAHModel2<R>
Source§fn clone(&self) -> ConstantVelocityXYAHModel2<R>
fn clone(&self) -> ConstantVelocityXYAHModel2<R>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<R> Freeze for ConstantVelocityXYAHModel2<R>
impl<R> RefUnwindSafe for ConstantVelocityXYAHModel2<R>
impl<R> Send for ConstantVelocityXYAHModel2<R>where
DefaultAllocator: Sized,
impl<R> Sync for ConstantVelocityXYAHModel2<R>where
DefaultAllocator: Sized,
impl<R> Unpin for ConstantVelocityXYAHModel2<R>
impl<R> UnsafeUnpin for ConstantVelocityXYAHModel2<R>
impl<R> UnwindSafe for ConstantVelocityXYAHModel2<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.