Main Content

Correction of measurement, state, and state estimation error covariance

The Kalman filter object is designed for tracking. You can use it to predict a physical object's future location, to reduce noise in the detected location, or to help associate multiple physical objects with their corresponding tracks. A Kalman filter object can be configured for each physical object for multiple object tracking. To use the Kalman filter, the object must be moving at constant velocity or constant acceleration.

The Kalman filter algorithm involves two steps, prediction and correction (also known as the update step). The first step uses previous states to predict the current state. The second step uses the current measurement, such as object location, to correct the state. The Kalman filter implements a discrete time, linear State-Space System.

**Note**

To make configuring a Kalman filter easier, you can use the `configureKalmanFilter`

object to configure a Kalman filter. It sets up the
filter for tracking a physical object in a Cartesian coordinate system, moving with constant
velocity or constant acceleration. The statistics are the same along all dimensions. If you
need to configure a Kalman filter with different assumptions, do not use the function, use
this object directly.

In the state space system, the state transition model, *A*, and the
measurement model, *H*, are set as follows:

Variable | Value |
---|---|

A | `[1 1 0 0; 0 1 0 0; 0 0 1 1; 0 0 0 1]` |

H | `[1 0 0 0; 0 0 1 0]` |

returns a
kalman filter for a discrete time, constant velocity system.`kalmanFilter`

= vision.KalmanFilter

additionally configures the control model, `kalmanFilter`

= vision.KalmanFilter(`StateTransitionModel`

,`MeasurementModel`

)*B*.

configures the Kalman filter object properties, specified as one or more
`kalmanFilter`

= vision.KalmanFilter(`StateTransitionModel`

,`MeasurementModel`

,`ControlModel`

,`Name,Value`

)`Name,Value`

pair arguments. Unspecified properties have default
values.

Use the `predict`

and `correct`

functions based on detection results. Use the `distance`

function to find the best matches.

When the tracked object is detected, use the

`predict`

and`correct`

functions with the Kalman filter object and the detection measurement. Call the functions in the following order:[...] = predict(

`kalmanFilter`

); [...] = correct(`kalmanFilter`

,*measurement*);When the tracked object is not detected, call the

`predict`

function, but not the`correct`

function. When the tracked object is missing or occluded, no measurement is available. Set the functions up with the following logic:[...] = predict(

`kalmanFilter`

); If*measurement*exists [...] = correct(`kalmanFilter`

,*measurement*); endIf the tracked object becomes available after missing for the past

*t*-1 contiguous time steps, you can call the`predict`

function*t*times. This syntax is particularly useful to process asynchronous video.. For example,for i = 1:k [...] = predict(kalmanFilter); end [...] = correct(kalmanFilter,measurement)

[1] Welch, Greg, and Gary Bishop,
*An Introduction to the Kalman Filter*, TR 95–041. University of North
Carolina at Chapel Hill, Department of Computer Science.

[2] Blackman, S.
*Multiple-Target Tracking with Radar Applications.* Artech House, Inc.,
pp. 93, 1986.