你好我正在学习OpenCV运动检测程序,目前我有这个错误说'语法错误:标识符BackgroundSubtractorMOG' 这是代码
int main()
{
string file_name, video_out;
Mat res, frameMOG, background, framegray, backgroundgray, prevframe;
int w = 0, h = 0, x = 0, y = 0, i = 0, j = 0, fps, fourcc = 0;
int enteredregion = 0;
int index = 0;
int currArea, prevArea = 0;
int cardetected, prevframecar;
//Reading Filename from user
cout << "Please enter file name without spaces: ";
cin >> file_name;
video_out = "output.mkv";
//Creating VideoCapture object for opening file
VideoCapture cap(file_name);
if (!cap.isOpened())
{
cout << "Could not open file";
return -1;
}
//Mog object creation for background subtraction
Ptr<BackgroundSubtractor> ptrMOG;
ptrMOG = new BackgroundSubtractorMOG(); // <-error points here
cap.read(background);
我还遇到了另一个错误():不是cv的成员:BackgroundSubtractor
frame.copyTo(current);
GaussianBlur(current, current, Size(9, 9), 0, 0, BORDER_DEFAULT);
cvtColor(current, framegray, CV_BGR2GRAY);
medianBlur(framegray, framegray, 9);
ptrMOG->operator()(framegray, frameMOG); // <--error points here
//absdiff(backgroundgray,framegray,frameMOG);
目前我不知道如何解决这些错误。我目前正在使用Visual Studio 2013和OpenCv 3.0。这是我的图书馆:
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/video/background_segm.hpp>