我在Qt中使用openCV3.1.0时遇到以下错误。我试图找到最稳定的图像区域。 Img是一个通道分离的图像,src是我的源图像。
错误:C2259:' cv :: MSER' :由于以下成员,无法实例化抽象类:
' void cv :: MSER :: detectRegions(cv :: InputArray,std :: vector< _Ty>&,std :: vector&)' :是抽象的
[Ty = std :: vector<<<<<&#> cv :: Point>> ]
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);
}
}
}
答案 0 :(得分:1)
您需要在声明之后创建MSER:
cv::Ptr<cv::MSER> mser = cv::MSER::create(5,10,120,0.1,.2,50,1.01,0.003,5);