kalman_filter
Kalman filter for tracking bounding boxes in image space.
KalmanFilter
KalmanFilter ()
A Kalman filter class designed for tracking bounding boxes in image space.
Attributes:
ndim
(int): The dimension of the state space._motion_mat
(ndarray): The motion model matrix._update_mat
(ndarray): The update matrix used for projecting state distribution to measurement space._std_weight_position
(float): Standard deviation weight for the position._std_weight_velocity
(float): Standard deviation weight for the velocity.
KalmanFilter.__init__
KalmanFilter.__init__ ()
Initialize the Kalman filter with default parameters.
KalmanFilter._create_std
KalmanFilter._create_std (mean:numpy.ndarray)
Compute standard deviations based on the mean.
Type | Details | |
---|---|---|
mean | ndarray | The mean values. |
Returns | ndarray | The computed standard deviations. |
KalmanFilter.initiate
KalmanFilter.initiate (measurement:numpy.ndarray)
Initialize a new track from an unassociated measurement.
Type | Details | |
---|---|---|
measurement | ndarray | The initial measurement for the track. |
Returns | tuple | The mean and covariance of the initiated track. |
KalmanFilter.predict
KalmanFilter.predict (mean:numpy.ndarray, covariance:numpy.ndarray)
Run the Kalman filter prediction step.
Type | Details | |
---|---|---|
mean | ndarray | The current state mean. |
covariance | ndarray | The current state covariance. |
Returns | tuple | The predicted state mean and covariance. |
KalmanFilter.project
KalmanFilter.project (mean:numpy.ndarray, covariance:numpy.ndarray)
Project the state distribution to the measurement space.
Type | Details | |
---|---|---|
mean | ndarray | The current state mean. |
covariance | ndarray | The current state covariance. |
Returns | tuple | The mean and covariance in the measurement space. |
KalmanFilter.multi_predict
KalmanFilter.multi_predict (mean:numpy.ndarray, covariance:numpy.ndarray)
Run the Kalman filter prediction step for multiple measurements (Vectorized version).
Type | Details | |
---|---|---|
mean | ndarray | The current state mean. |
covariance | ndarray | The current state covariance. |
Returns | tuple | The predicted state mean and covariance for multiple measurements. |
KalmanFilter.update
KalmanFilter.update (mean:numpy.ndarray, covariance:numpy.ndarray, measurement:numpy.ndarray)
Run the Kalman filter correction step.
Type | Details | |
---|---|---|
mean | ndarray | The predicted state mean. |
covariance | ndarray | The predicted state covariance. |
measurement | ndarray | The new measurement. |
Returns | tuple | The updated state mean and covariance after correction. |
KalmanFilter.gating_distance
KalmanFilter.gating_distance (mean:numpy.ndarray, covariance:numpy.ndarray, measurements:numpy.ndarray, only_position:bool=False, metric:str='maha')
Compute the gating distance between the state distribution and given measurements.
Raises: ValueError: If an invalid distance metric is provided.
Type | Default | Details | |
---|---|---|---|
mean | ndarray | The state mean. | |
covariance | ndarray | The state covariance. | |
measurements | ndarray | The given measurements. | |
only_position | bool | False | If True, consider only position in the gating distance. Defaults to False. |
metric | str | maha | The metric to use for distance calculation (‘gaussian’ or ‘maha’). Defaults to ‘maha’. |
Returns | ndarray | The gating distances. |