Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KalmanFilter(6,2,0) transition matrix

I am working on a object tracking project and I want to improve the results I am getting using a Kalman filter.

I have found a lot of examples on the internet which are working but I really want to understand what is behind it.

Using opencv, here is a part of the code :

KalmanFilter KF(6, 2, 0);
Mat_ state(6, 1); 
Mat processNoise(6, 1, CV_32F);
...
KF.statePre.at(0) = mouse_info.x;
KF.statePre.at(1) = mouse_info.y;
KF.statePre.at(2) = 0;
KF.statePre.at(3) = 0;
KF.statePre.at(4) = 0;
KF.statePre.at(5) = 0;
KF.transitionMatrix = *(Mat_(6, 6) << 1,0,1,0,0.5,0, 0,1,0,1,0,0.5, 0,0,1,0,1,0, 0,0,0,1,0,1, 0,0,0,0,1,0, 0,0,0,0,0,1);
KF.measurementMatrix = *(Mat_(2, 6) << 1,0,1,0,0.5,0, 0,1,0,1,0,0.5);

This one gives smoother results than a KalmanFilter(4,2,0) but I don't really understand why. Can someone explain me what is behind this (6,6) transition matrix ?

EDIT : The solution is probably here but obviously I am not good enough to find it by myself ...

Thank you for your help.

like image 311
Thibel Avatar asked Jul 24 '13 14:07

Thibel


People also ask

What is Kalman filter transition matrix?

The transition model is then used in several parts in the Kalman filter. First, to describe the variance and the position of your robot at time point i. And it is part of formulating the prediction error (Kalman gain) of your sensor model to minimize the variance of your next measure.

What is 2D Kalman filter?

A 2D Kalman Filter is designed to track a moving target.

What do you mean by state transition matrix?

The state-transition matrix is a matrix whose product with the state vector x at the time t0 gives x at a time t, where t0 denotes the initial time. This matrix is used to obtain the general solution of linear dynamical systems. It is represented by Φ.

What is observation matrix in Kalman filter?

The observation matrix transforms the predicted state into a vector so that the difference can be taken and kalman gain applied.


1 Answers

You have a state vector X made up of 6 components, the first two of which are the x and y position of an object; let's assume that the other 4 are their velocities and accelerations:

X = [x, y, v_x, v_y, a_x, a_y] t

In the Kalman filter, your next state, Xt+1, is equal to the previous state Xt multiplied by the transition matrix A, so with the transition matrix you posted, you would have:

x t+1 = x t + v_x t + 0.5 a_x t

y t+1 = y t + v_y t + 0.5 a_y t

v_x t+1 = v_x t + a_x t

v_y t+1 = v_t t + a_t t

a_x t+1 = a_x t

a_y t+1 = a_y t

Which are the discrete approximation of the equations of an object moving with constant acceleration if the time interval between the two states is equal to 1 (and that's why it makes sense to suppose that the other four variables are velocities and accelerations).

This is a Kalman filter that allows for faster variations in the velocity estimation, so it introduces a lower delay than a (4, 2, 0) filter, which would use a constant velocity model.

like image 163
Milo Avatar answered Oct 25 '22 16:10

Milo