MotionModel
- class btrack.models.MotionModel(*, measurements: int, states: int, A: ndarray[Any, dtype[_ScalarType_co]], H: ndarray[Any, dtype[_ScalarType_co]], P: ndarray[Any, dtype[_ScalarType_co]], R: ndarray[Any, dtype[_ScalarType_co]], G: ndarray[Any, dtype[_ScalarType_co]] | None = None, Q: ndarray[Any, dtype[_ScalarType_co]] | None = None, dt: float = 1.0, accuracy: float = 2.0, max_lost: int = 5, prob_not_assign: float = 0.1, name: str = 'Default')
Bases:
BaseModel
The btrack motion model.
- Parameters:
- namestr
A name identifier for the model.
- measurementsint
The number of measurements of the system (e.g. 3 for x, y, z).
- statesint
The number of states of the system (typically >= measurements). The standard states for a constant velocity model are (x, y, z, dx, dy, dz), i.e. 6 in total for 3 measurements.
- Aarray (states, states)
State transition matrix.
- Harray (measurements, states)
Observation matrix.
- Parray (states, states)
Initial covariance estimate.
- Garray (1, states), optional
Simplified estimated error in process. Is used to calculate Q using Q = G.T @ G. Either G or Q must be defined.
- Qarray (states, states), optional
Full estimated error in process. Either G or Q must be defined.
- Rarray (measurements, measurements)
Estimated error in measurements.
- dtfloat
Time difference (always 1).
- accuracyfloat
Integration limits for calculating the probabilities.
- max_lostint
Number of frames without observation before marking as lost.
- prob_not_assignfloat
The default probability to not assign a track.
Notes
Uses a Kalman filter [1]:
‘Is an algorithm which uses a series of measurements observed over time, containing noise (random variations) and other inaccuracies, and produces estimates of unknown variables that tend to be more precise than those that would be based on a single measurement alone.’
Predicted estimate of state:
\[\hat{x}_{t\vert~t-1} = A_t \hat{x}_{t-1\vert~t-1}\]Predicted estimate of covariance:
\[P_{t\vert~t-1} = A_t P_{t-1\vert~t-1} A_t^{\top} + Q_t\]This is just a wrapper for the data with a few convenience functions thrown in. Matrices must be stored Fortran style, because Eigen uses column major and Numpy uses row major storage.
References
[1]‘A new approach to linear filtering and prediction problems.’ Kalman RE, 1960 Journal of Basic Engineering
Methods Summary
parse_arrays
(v)reshape_A
(a, values)reshape_G
(g, values)reshape_H
(h, values)reshape_P
(p, values)reshape_Q
(q, values)reshape_R
(r, values)validate_motion_model
(values)Methods Documentation
- classmethod parse_arrays(v)
- classmethod reshape_A(a, values)
- classmethod reshape_G(g, values)
- classmethod reshape_H(h, values)
- classmethod reshape_P(p, values)
- classmethod reshape_Q(q, values)
- classmethod reshape_R(r, values)
- classmethod validate_motion_model(values)