OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 03 Sep 2012 05:23:59 -0500cv::KalmanFilter some questionshttp://answers.opencv.org/question/1922/cvkalmanfilter-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
VladThu, 30 Aug 2012 05:35:21 -0500http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/Comment by sammy for <p>Hi,
I have some questions about the Kalman filter implementation.</p>
<p>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.</p>
<p>so the Kalmanfilter have to be initilized with init(2,1);</p>
<p>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?</p>
<p>in my understanding the kalman just needs one state (s, s') and a covariance matrix(2x2) <br>
The whole process works like this:</p>
<pre><code> 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
</code></pre>
<p>so state and covar always contain the correct data.</p>
<p>so why cv::Klamnafilter requires statePre and statePost?
which one contains the valid state?
what happens in the following scenario:</p>
<pre><code> init
predict
update
predict
// no measurement
predict
// no measurement
predict
update
</code></pre>
<p>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?</p>
<p>That are all the temp matrices?
The class design looks a bit awkward to me.</p>
<p>Thanks
Vlad</p>
http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=1923#post-id-1923statePre 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-1Thu, 30 Aug 2012 06:10:31 -0500http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=1923#post-id-1923Comment by vlad_tepesch for <p>Hi,
I have some questions about the Kalman filter implementation.</p>
<p>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.</p>
<p>so the Kalmanfilter have to be initilized with init(2,1);</p>
<p>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?</p>
<p>in my understanding the kalman just needs one state (s, s') and a covariance matrix(2x2) <br>
The whole process works like this:</p>
<pre><code> 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
</code></pre>
<p>so state and covar always contain the correct data.</p>
<p>so why cv::Klamnafilter requires statePre and statePost?
which one contains the valid state?
what happens in the following scenario:</p>
<pre><code> init
predict
update
predict
// no measurement
predict
// no measurement
predict
update
</code></pre>
<p>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?</p>
<p>That are all the temp matrices?
The class design looks a bit awkward to me.</p>
<p>Thanks
Vlad</p>
http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=2007#post-id-2007thanks for the linkMon, 03 Sep 2012 05:23:59 -0500http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=2007#post-id-2007Answer by kevin for <p>Hi,
I have some questions about the Kalman filter implementation.</p>
<p>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.</p>
<p>so the Kalmanfilter have to be initilized with init(2,1);</p>
<p>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?</p>
<p>in my understanding the kalman just needs one state (s, s') and a covariance matrix(2x2) <br>
The whole process works like this:</p>
<pre><code> 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
</code></pre>
<p>so state and covar always contain the correct data.</p>
<p>so why cv::Klamnafilter requires statePre and statePost?
which one contains the valid state?
what happens in the following scenario:</p>
<pre><code> init
predict
update
predict
// no measurement
predict
// no measurement
predict
update
</code></pre>
<p>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?</p>
<p>That are all the temp matrices?
The class design looks a bit awkward to me.</p>
<p>Thanks
Vlad</p>
http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?answer=1969#post-id-1969Take a look at how Kalman filters [work](http://en.wikipedia.org/wiki/Kalman_filter) 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.Fri, 31 Aug 2012 21:39:19 -0500http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?answer=1969#post-id-1969Comment by vlad_tepesch for <p>Take a look at how Kalman filters <a href="http://en.wikipedia.org/wiki/Kalman_filter">work</a> 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.</p>
http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=2006#post-id-2006thanks, 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.
Mon, 03 Sep 2012 05:23:44 -0500http://answers.opencv.org/question/1922/cvkalmanfilter-some-questions/?comment=2006#post-id-2006