# cv::KalmanFilter some questions

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

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

thanks for the link