【发布时间】: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。