mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 22:40:17 +08:00
let Kalman handle the missing measurements (bug #1380)
This commit is contained in:
parent
2abb67cc92
commit
cb58e5a3a4
@ -172,6 +172,9 @@ cvKalmanPredict( CvKalman* kalman, const CvMat* control )
|
||||
cvGEMM( kalman->temp1, kalman->transition_matrix, 1, kalman->process_noise_cov, 1,
|
||||
kalman->error_cov_pre, CV_GEMM_B_T );
|
||||
|
||||
/* handle the case when there will be measurement before the next predict */
|
||||
cvCopy(kalman->state_pre, kalman->state_post);
|
||||
|
||||
return kalman->state_pre;
|
||||
}
|
||||
|
||||
@ -261,6 +264,9 @@ const Mat& KalmanFilter::predict(const Mat& control)
|
||||
// P'(k) = temp1*At + Q
|
||||
gemm(temp1, transitionMatrix, 1, processNoiseCov, 1, errorCovPre, GEMM_2_T);
|
||||
|
||||
// handle the case when there will be measurement before the next predict.
|
||||
statePre.copyTo(statePost);
|
||||
|
||||
return statePre;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,8 @@ int main(int, char**)
|
||||
line( img, statePt, measPt, Scalar(0,0,255), 3, CV_AA, 0 );
|
||||
line( img, statePt, predictPt, Scalar(0,255,255), 3, CV_AA, 0 );
|
||||
|
||||
KF.correct(measurement);
|
||||
if(theRNG().uniform(0,4) != 0)
|
||||
KF.correct(measurement);
|
||||
|
||||
randn( processNoise, Scalar(0), Scalar::all(sqrt(KF.processNoiseCov.at<float>(0, 0))));
|
||||
state = KF.transitionMatrix*state + processNoise;
|
||||
|
Loading…
Reference in New Issue
Block a user