I have same the problem like this topic BackgroundSubtractorMOG2 & OpenCV
Before i use opencv 2.4.9, i have deleted opencv 3.0.0. And now when i use class BackgroundSubtractorMOG2 then i have this prolem.
How can i resolve it. I'm using eclipse. Please, help me.
My source code:
int main(int argc, char *argv[]) {
cv::Mat frame;
cv::Mat back;
cv::Mat fore;
cv::VideoCapture cap(0);
cv::BackgroundSubtractorMOG2 bg;
bg.set("nmixtures", 3);
//bg.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;
}
return 0;}
Change the code like this . It will work .