Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
for the below code how can i apply kalman filter algorithm. I am able to detect the object and draw contours.

C++
#include
#include<iostream>
#include<vector>

int main(int argc, char *argv[])
{
    cv::Mat frame;
    cv::Mat back;
    cv::Mat fore;
    cv::VideoCapture cap("c:/dev/projects/opencv_test/kalman.avi");
    cv::BackgroundSubtractorMOG2 bg;
    bg.nmixtures = 3;
    bg.bShadowDetection = false;

    std::vector<std::vector xmlns:std="#unknown"><cv::point xmlns:cv="#unknown"> &gt; contours;

    cv::namedWindow("Frame");
    cv::namedWindow("Background");

    for(;;)
    {
        cap &lt;&lt;frame;
        bg.operator ()(frame,fore);
        bg.getBackgroundImage(back);
        cv::erode(fore,fore,cv::Mat());
        cv::dilate(fore,fore,cv::Mat());
        cv::findContours(fore,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
        cv::drawContours(frame,contours,-1,cv::Scalar(0,0,255),2);
        cv::imshow("Frame",frame);
        cv::imshow("Background";,back);
        if(cv::waitKey(30) &gt;= 0) break;
    }
    return 0;
}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 21-Feb-14 22:00pm
v2
Comments
enhzflep 22-Feb-14 2:22am    
You may wish to review and update your post. The first file #included is missing entirely from your post and there seem to be some erroneous tags in the middle of the post somewhere.
You should make a point to wrap the code in code-tags (make sure the code is html-encoded - '<' should be written as '&lt;', '>' as '&gt;'). Failure to do so will cause statements such as vector<int> to appear something like vector
(This is why your includes aren't showing-up properly. The angled brackets aren't html-encoded)

The editor should html-encode and wrap code-tags around your code when you paste it.
Member 10366626 23-Feb-14 23:06pm    
That is not the problem i am talking about. I have copy paste the code so it is comming like that. I am able to run the program succesfully. For the code above i want to apply kalman filter can you please help me on this
enhzflep 23-Feb-14 23:20pm    
I know that's the the problem you came here seeking help for. It is however, a problem with the way you've posted the code. You can fix the post at any-time you want. It is currently invalid as shown. Better posted questions generally attract better quality answers. If you cant even be bothered to make sure the code appears here as it does in your IDE, what makes you think someone will be bothered to put in the effort required to help you?


As for the Kalman filter, sorry no I can't help you with it, I know nothing of it other than how to spell its name.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900