Ask Your Question
1

Error in BackgroundSubtraction Mog2

asked 2013-06-25 05:21:30 -0500

FLY gravatar image

I am using opencv 2.4.4 and when i run this algorithm on it , it give me the error on nmixtures and bShadowDetection

    cv::VideoCapture cap("try2.avi");
    cv::BackgroundSubtractorMOG2 bg;
    bg.nmixtures = 3;
    bg.bShadowDetection = false;
//When i use it like below , it didn't give syntax error , but give me error at runtime bg.set("nmixtures", 3); bg.set("bShadowDetection", false);

    std::vector<std::vector<cv::Point> > contours;

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

    for(;;)
    {
        cap >> 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) >= 0) break;
    }

Error's

error C2248: 'cv::BackgroundSubtractorMOG2::nmixtures' : cannot access protected member declared in class 'cv::BackgroundSubtractorMOG2'
`error C2248: 'cv::BackgroundSubtractorMOG2::bShadowDetection' : cannot access protected member declared in class 'cv::BackgroundSubtractorMOG2`'   

    error LNK2019: unresolved external symbol "public: virtual void __thiscall cv::BackgroundSubtractorMOG2::operator()(class cv::_InputArray const &,class cv::_OutputArray const &,double)" (??RBackgroundSubtractorMOG2@cv@@UAEXABV_InputArray@1@ABV_OutputArray@1@N@Z) referenced in function _main
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-06-25 05:43:43 -0500

berak gravatar image

afaik, the public/protected status of those members has changed in 2.4.5

try passing the values to the constructor

edit flag offensive delete link more

Comments

I mention above that i assign it through constructor , but still it shows error , any other option ?

FLY gravatar imageFLY ( 2013-06-25 05:45:17 -0500 )edit

Is this problem is solved in 2.4.5 , if i use it ?

FLY gravatar imageFLY ( 2013-06-25 05:50:34 -0500 )edit

i don't know(haven't got 2.4.5), things seem to change rapidly there.

did you try the sample, that came with 2.4.4 ?

there seems to be a mismatch between your code above , and your opencv version

berak gravatar imageberak ( 2013-06-25 06:13:59 -0500 )edit
0

answered 2013-06-25 21:42:16 -0500

Shaban gravatar image

updated 2013-06-25 21:43:47 -0500

I'm using 2.4.5 too and I've resolved this error, you need to change nmixtures & bShadowDetection from protected to public on background_segm.hpp ;)

edit flag offensive delete link more

Comments

i did it , but its not working for me , well my version is 2.4.4

FLY gravatar imageFLY ( 2013-06-26 03:29:47 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-25 05:21:30 -0500

Seen: 1,530 times

Last updated: Jun 25 '13