Object of abstract class type “cv::BackgroundSubtractorMOG2” is not allowed. all the methods are pure virtual

吃可爱长大的小学妹 提交于 2019-12-06 02:33:46

Syntax has changed from OpenCV 2.9.X. This will work in OpenCV 3.0.0:

#include <opencv2\opencv.hpp>

using namespace cv;
using namespace std;
int main() {
    VideoCapture video("1.avi");
    Mat frame, mask, thresholdImage, output;
    int frameNum = 0;

    Ptr<BackgroundSubtractor> pMOG2 = createBackgroundSubtractorMOG2(20, 16, true);
    while (true) {
        video >> frame;
        ++frameNum;
        pMOG2->apply(frame, mask, 0.001);

        cout << frameNum << endl;
        imshow("mask",mask);
        waitKey(10);
    }
    return 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!