Ask Your Question
2

cv::KalmanFilter some questions

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

vlad_tepesch gravatar image

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

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:

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

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

  update
    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:

  init 
  predict
  update
  predict
  // no measurement 
  predict
  // no measurement 
  predict
  update

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

Comments

3

statePre keeps the state before correct() is called. statePost() contains the corrected state (the expected Kalman result). Also check this out: http://code.opencv.org/issues/1380#note-1

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

thanks for the link

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

1 answer

Sort by ยป oldest newest most voted
2

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

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

Comments

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 -0600 )edit

Question Tools

Stats

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

Seen: 1,980 times

Last updated: Apr 25 '14