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.
opencv3.4.1 It worked well without the bgs. I used cv::absdiff before.
sorry, but i cannot reproduce your problem.
https://docs.opencv.org/3.4.1/de/de1/...
and it's still a compiler problem (so, something about headers, not libs)
Could it be because of some unnecessary headers?
not really, but for sure you should remove the stdafx.h shit (that's from MFC, 2 decades ago)
also try to disable "precompiled headers" in general.
try with a clean "empty" project. all you should need for the bgMOG2 is "opencv2/video.hpp"
Removing stdafx created an other error. However, moving it to the top of the file seems to have fixed the error!
that's interesting, again it hints at a problem with precompiled headers.
and you really should NOT use stdafx.h with opencv projects. see, what's in there, and move anything you need into your main program, and throw anything else (does it have "windows.h ? omg !) away.
oh, let me guess: problems with
ACCESS_READ
or such ? really, get rid ofwindows.h
thereThank you for the help!
maybe you could write an answer, describing, what you did, in the end ?
might be quite helpful for others ;)