Reputation: 498
I have recently installed OpenCv in my ubuntu 14.10 system and I was running a program and in fuction cv::BackgroundSubtractorMOG2
I am facing an error.
Error is cannot declare variable ‘bg’ to be of abstract type ‘cv::BackgroundSubtractorMOG2’
Why I am facing this error
My code sample
int main(int argc, char *argv[]) {
Mat frame;
Mat back;
Mat front;
vector<pair<Point,double> > hand_middle;
VideoCapture cap(0);
BackgroundSubtractorMOG2 bg; //Here I am facing error
bg.set("nmixtures",3);
bg.set("detectShadows",false);
//Rest of my code
return 0;
}
Upvotes: 4
Views: 4451
Reputation: 39796
the api changed in opencv3.0, you will have to use:
cv::Ptr<BackgroundSubtractorMOG2> bg = createBackgroundSubtractorMOG2(...)
bg->setNMixtures(3);
bg->apply(img,mask);
Upvotes: 5
Reputation: 2025
API in OpenCV 3.0 is now abstract.
cv::Ptr<cv::BackgroundSubtractor> pMOG2;
pMOG2 = cv::createBackgroundSubtractorMOG2();
pMOG2->apply(frame, fgMaskMOG2);
Also Please fallow that link: http://docs.opencv.org/master/d1/dc5/tutorial_background_subtraction.html
Upvotes: 1