Ask Your Question

cv::KalmanFilter some questions

asked 2012-08-30 05:35:21 -0500

vlad_tepesch gravatar image

updated 2014-04-25 08:00:09 -0500

Hi, I have some questions about the Kalman filter implementation.

I have an object that contains some state(1d) that should be tracked with an 1D kalman filter. The state of the Kalman should contain the state and its first derivative.

so the Kalmanfilter have to be initilized with init(2,1);

My Questions: qhich of the public members is the current state? statePre or statePost? why are there two states? and which holds the current covariances?

in my understanding the kalman just needs one state (s, s') and a covariance matrix(2x2)
The whole process works like this:

    state <- init from measurement and default derivative
    covar <- initial Covars from measurement variance

    state <- state * transition
    covar <- new covar (build from current covar and process noise)

    state <- fancy calculations using oldstate, newstate and variances
    covar <- more fancy calculations

so state and covar always contain the correct data.

so why cv::Klamnafilter requires statePre and statePost? which one contains the valid state? what happens in the following scenario:

  // no measurement 
  // no measurement 

how does later parts of algorithm should know if they should read statePre or statePost? have i allways to store if there was an update or not and read the other member if i want the current state?

That are all the temp matrices? The class design looks a bit awkward to me.

Thanks Vlad

edit retag flag offensive close merge delete



statePre keeps the state before correct() is called. statePost() contains the corrected state (the expected Kalman result). Also check this out:

sammy gravatar imagesammy ( 2012-08-30 06:10:31 -0500 )edit

thanks for the link

vlad_tepesch gravatar imagevlad_tepesch ( 2012-09-03 05:23:59 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-08-31 21:39:19 -0500

kevin gravatar image

Take a look at how Kalman filters work and note there is a pre-state (a priori) and a post state (a posteriori). The post state is the estimate which is a combination of the pre-state and a residual multiplied by the Kalman gain.

edit flag offensive delete link more


thanks, i know about kalman filters. I wrote my own now, that fits my needs. There is no need to store a post and a pre state (beside to debugging). Normally there is only one state that is changed by predict and update step. if you read the state you always get the best possible estimation regardless whether there was an update or not. Sammy already posted a link to a bug report.

vlad_tepesch gravatar imagevlad_tepesch ( 2012-09-03 05:23:44 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2012-08-30 05:35:21 -0500

Seen: 1,504 times

Last updated: Apr 25 '14