简体   繁体   中英

cv has no member BackgroundSubtractorMOG

I am new to opencv and followed instructions to install it as described here: http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation I used the section "Installation by Making Your Own Libraries from the Source Files", which worked well (using Visual Studio 2013). I am able to run basic commands, like read an image, write an image, run edge detection, video processing etc. But now I tried to use BackgroundSubtractorMOG and I get the error that BackgroundSubtractorMOG is not a member of cv. The simplest code is below and I don't know where to start. Am I missing something in my installation? Any ideas?

#include "stdafx.h"
#include<opencv2/opencv.hpp>

int main()
{
    cv::BackgroundSubtractorMOG bg;
    return 0;
}

with opencv3.0, BackgroundSubtractorMOG was moved to the opencv_contrib repo

to use the remaining BackgroundSubtractorMOG2 or BackgroundSubtractorKNN you'd have to use:

Ptr<BackgroundSubtractorMOG2> bgm = createBackgroundSubtractorMOG2(...);

you forgot to include the header

#include <background_segm.hpp>

Reference: http://physics.nyu.edu/grierlab/manuals/opencv/classcv_1_1BackgroundSubtractorMOG.html

path to the header file could be: /opencv2/video/background_segm.hpp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM