【问题标题】:error: C2259: 'cv::MSER' : Cannot instantiate abstract class错误:C2259:'cv::MSER':无法实例化抽象类
【发布时间】:2016-05-04 06:27:10
【问题描述】:

在 Qt 中使用 openCV3.1.0 时出现以下错误。我正在尝试找到图像的最稳定区域。 img 是通道分离的图像,src 是我的源图像。

错误:C2259:'cv::MSER':由于以下成员,无法实例化抽象类:

'void cv::MSER::detectRegions(cv::InputArray,std::vector<_ty> &,std::vector &)' : 是抽象的

[ Ty=std::vector> ]

   void hello(Mat& Img , Mat& src)
        {
          vector< vector< Point> > contours;
          Ptr<MSER> mser;
          vector<Rect> Boxes;
          MSER(5,10,120,0.1,.2,50,1.01,0.003,5)(Img,contours);

         for(int  i = 0 ; i  < contours.size() ; i++)
         boundRect[i] = boundingRect( Mat(contours[i]) );

         for( int i = 0; i < contours.size(); i++ )
         {
            float width_heightRatio = (float)(boundRect[i].width/float(boundRect[i].height) );

            if( width_heightRatio < 1)
            {
              Mat Image = rectangle(src,boundRect[i],Scalar(0,0,255));
              cvNamedWindow("Test");
              imshow("Test",Image); 
              cvWaitKey(10);
            }

         }
}

【问题讨论】:

  • 您对MSER 的使用存在许多问题,也许可以查看 OpenCV 源代码,了解如何实例化和使用检测器的示例。例如,查看\sources\modules\features2d\test\test_mser.cpp

标签: qt opencv


【解决方案1】:

你需要在声明like后创建MSER:

cv::Ptr<cv::MSER> mser = cv::MSER::create(5,10,120,0.1,.2,50,1.01,0.003,5);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-25
    • 2012-08-15
    • 1970-01-01
    • 1970-01-01
    • 2013-05-13
    • 2019-03-13
    • 1970-01-01
    相关资源
    最近更新 更多