How to declare and initial BackgroundSubtractorMOG2 in opencv3.
Hi all, i try many different methods to declare and intial backgoundsubtractormog2 classs. But i always fails, i list all i declare. Someone can tell me how to declare or has any idea or any referance can help me? I appreciate your help.
Ptr<BackgroundSubtractor> MOG2model=createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubtractor>();//Fail
Ptr<BackgroundSubtractorMOG2> MOG2model = createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubtractorMOG2>();//Fail
Ptr<BackgroundSubtractorMOG2> MOG2model = createBackgroundSubtractorMOG2();//Fail
cv::BackgroundSubtractorMOG2 MOG2model=BackgroundSubtractorMOG2::create<BackgroundSubtractorMOG2>("Background");//Fail
by the way, thanks very much!
Ptr<BackgroundSubtractor> MOG2model=createBackgroundSubtractorMOG2();
should just work, same asPtr<BackgroundSubtractorMOG2> MOG2model=createBackgroundSubtractorMOG2();
.what's the error in your case ? why the dynamic_cast() ?
Hi,berak
Ptr<BackgroundSubtractor> MOG2model=createBackgroundSubtractorMOG2();
// I getC2143 Syntax Error ,lost ";" (before <) and error C4430 ,error C2238
Ptr<BackgroundSubtractorMOG2> MOG2model=createBackgroundSubtractorMOG2();
// the same I find example "bgfg_segm.cpp" so, i trycreateBackgroundSubtractorMOG2().dynamicCast<BackgroundSubtractor>();
are you using CLI/managed c++ ?
No, pure C++,enviroment does not support CLI. But I think I use different version complier. I check again.
can it be, there's a missing
;
before your statements ? (like, one or more lines up ?) , or something like unmatched {} () or such , again, in the lines above those statements ?I mark this statement ,then it's ok. I change platform tool to VS2012(opencv lib is bulided VS2012) is the scame. But now I write code using VS2013. I think i use different version. I bulid VS2013 opencv lib now:)
hmm, that's still a compiler error. the libs won't change anything, i'm afraid.