Opencv kalman filter prediction without new observtion

前端 未结 3 1408
攒了一身酷
攒了一身酷 2020-12-13 21:31

I wan to use Opencv Kalman filter implementation for smooth some noise points. So I\'ve tried to code a simple test for it.

Let\'s say I have an observation (a point

相关标签:
3条回答
  • 2020-12-13 22:13

    I didn't set the transition and measurement matrix.

    I have found standard state-space values for those matrix in this excellent MATLAB documentation page.

    0 讨论(0)
  • 2020-12-13 22:14

    For those people who still have problem in using OpenCV Kalman filtering

    The above posted code works well after small modification. Instead of setting transition matrix to Identity, you can set as follows.

    Modification

    KF.transitionMatrix = *(Mat_<float>(4, 4) << 1,0,1,0,   0,1,0,1,  0,0,1,0,  0,0,0,1);  
    

    Output

    enter image description here

    0 讨论(0)
  • 2020-12-13 22:21

    After every prediction, you should copy the predicted state (statePre) into the corrected state (statePost). This should also be done for the state covariance (errorCovPre -> errorCovPost). This prevents the filter from getting stuck in a state when no corrections are executed. The reason is that predict() makes use of the state values stored in statePost, that do not change if no corrections are called.

    Your kalmanPredict function will then be as follows:

    Point kalmanPredict() 
    {
        Mat prediction = KF.predict();
        Point predictPt(prediction.at<float>(0),prediction.at<float>(1));
    
        KF.statePre.copyTo(KF.statePost);
        KF.errorCovPre.copyTo(KF.errorCovPost);
    
        return predictPt;
    }
    
    0 讨论(0)
提交回复
热议问题