首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >‘'class cv::BackgroundSubtractorMOG2 2’没有名为'operator()‘的成员

‘'class cv::BackgroundSubtractorMOG2 2’没有名为'operator()‘的成员
EN

Stack Overflow用户
提问于 2018-12-19 12:38:44
回答 1查看 622关注 0票数 1

我正在尝试编译这个c++应用程序。

代码语言:javascript
复制
int main ()
{
  Mat frame;
  Mat back;
  Mat fore;
  VideoCapture cap1;
  cap1.open(0);  /*to capture from camera*/
  cv::Ptr<BackgroundSubtractorMOG> pMOG = createBackgroundSubtractorMOG();
cv::Ptr<BackgroundSubtractorMOG2> pMOG2 = createBackgroundSubtractorMOG2();
  pMOG2->setNMixtures(10);
  vector < vector < Point > >contours;
  namedWindow ("Frame");
  int i=0;

  for (;;)
    {
    cap1 >> frame;
    pMOG2->operator()(frame, fore);
    pMOG2->getBackgroundImage (back);
    erode (fore, fore, cv::Mat ());
    erode (fore, fore, cv::Mat ());
    dilate (fore, fore, cv::Mat ());
    dilate (fore, fore, cv::Mat ());
    dilate (fore, fore, cv::Mat ());
    findContours (fore, contours, CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
    drawContours (frame, contours, -1, Scalar (255, 255, 255), 1);
    Scalar color = Scalar(200,200,200);
    int a=0;
    vector<Rect> boundRect( contours.size() );
    for( int i = 0; i < contours.size(); i++ )
      {
           boundRect[i] = boundingRect( contours[i] );
      }
    for( i = 0; i< contours.size(); i++ )
     {
        if(boundRect[i].width>=40 || boundRect[i].height>=40)//eliminates small boxes
            {
                a=a+(boundRect[i].height)*(boundRect[i].width);
             }
        //  cout<<"Net contour area is "<<a<<"\n";
        if(a>=int(frame.rows)*int(frame.cols)/2)//change denominator as per convenience
            {
                putText(frame,"Tampering",Point(5,30),FONT_HERSHEY_SIMPLEX,1,Scalar(0,255,255),2);
                cout<<"\a";
            }
       }
   imshow ("Frame", frame);
   waitKey(10);  
 }

在编译时,我得到了以下错误

错误:

Tampering.cpp:27:21: error:'class cv::BackgroundSubtractorMOG2 2‘没有名为'operator()’pMOG2 2->operator()的成员(frame,fore);

我的opencv版本-3.3.0

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2018-12-21 04:53:32

首先,感谢您订阅我的存储库:https://github.com/SaranshKejriwal/Tampering-Detection/blob/master/Tampering%20main/Tampering.cpp

在我的例子中,我使用了openCV 2.4.5,它在BackgroundSubtractorMOG2类中具有operator()方法。

由于您使用的是openCV 3.3.0,我鼓励您查看文档,以验证该方法是否仍然存在

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53851465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档