【发布时间】:2015-09-10 05:19:58
【问题描述】:
我正在使用 Motion Detector Script,但是当我运行我的代码时,每次使用此功能时都会出现此错误,但我不知道为什么会出错。
我正在使用opencv3,下面是我的代码。我尝试运行其他示例,我将它从 web 获取到相同的功能,但错误仍然存在。任何想法来解决它?
这是错误:
cv.cpp:在函数'int main()'中:
cv.cpp:23:4: 错误:‘BackgroundSubtractorMOG’不是‘cv’的成员
我的代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <iostream>
#include <sstream>
#include <opencv2/video/background_segm.hpp>
using namespace std;
int main()
{
//Openthevideofile
cv::VideoCapture capture("/home/shar/Desktop/op.mp4");
//checkifvideosuccessfullyopened
if (!capture.isOpened())
return 0;
//currentvideoframe
cv::Mat frame;
//foregroundbinaryimage
cv::Mat foreground;
cv::namedWindow("ExtractedForeground");
//TheMixtureofGaussianobject
//used with all default parameters
cv::BackgroundSubtractorMOG mog;
bool stop(false);
//forallframesinvideo
while(!stop){
//readnextframeifany
if(!capture.read(frame))
break;
//updatethebackground
//andreturntheforeground
mog(frame,foreground,0.01)
//learningrate
//Complementtheimage
cv::threshold(foreground,foreground,128,255,cv::THRESH_BINARY_INV);
//showforeground
cv::imshow("ExtractedForeground",foreground);
//introduceadelay
//orpresskeytostop
if(cv::waitKey(10)>=0)
stop=true;
}
}
【问题讨论】: