Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

BackgroundSubtractor is not a member of 'cv' on VS17 C++

I'm building a background subtractor on Visual Studio 17. I've included the opencv_world.dll. When typing cv::Bac autofinish offers BackgroundSubtractor and moving poiter to it shows correct info about it. But when i build the project, it throws errors.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/video/background_segm.hpp>
#include <opencv2/video.hpp>
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>

using namespace std;
using namespace cv;

cv::Ptr<cv::BackgroundSubtractor> backsub = cv::createBackgroundSubtractorMOG2(200, 125, false);

This throws errors like:

'BackgroundSubtractor': is not a member of 'cv'
'BackgroundSubtractor': undeclared identifier

I tried adding opencv_contrib NuGet package, but that did not help. Also tried including all sorts of header files, using bgsegm::createBackgroundSubtractorMOG, cv::createBackgroundSubtractorMOG2.