【发布时间】:2014-03-24 03:59:11
【问题描述】:
我正在尝试使用轮廓函数查找连接的组件,但 findContours 函数出现错误。我正在使用 opencv 2.4.7 和 Visual Studio 2010
CvMat *mat = cvCreateMat(img->height,img->width,CV_32FC3 );
cvConvert( img, mat );
CvMat *thr = cvCreateMat(img->height,img->width,CV_32FC3);
cvCvtColor(mat,thr ,CV_RGBA2RGB);
cvThreshold(thr, thr,25, 255,CV_THRESH_BINARY); //Threshold the gray
int largest_area=0;
int largest_contour_index=0;
Rect bounding_rect;
vector<vector<Point>> contours; // Vector for storing contour
vector<Vec4i> hierarchy;
findContours( thr, contours, hierarchy,CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); //Find the contours in the image
错误:
IntelliSense: no suitable conversion function from "std::vector<std::vector<cv::Point, std::allocator<cv::Point>>, std::allocator<std::vector<cv::Point, std::allocator<cv::Point>>>>" to "CvMemStorage *" exists c:\users\shahd\documents\visual studio 2010\projects\test_opencv\test_opencv\main.cpp 41
IntelliSense: no suitable conversion function from "std::vector<cv::Vec4i, std::allocator<cv::Vec4i>>" to "CvSeq **" exists c:\users\shahd\documents\visual studio 2010\projects\test_opencv\test_opencv\main.cpp 41
【问题讨论】:
-
没有看到你的其余代码,这很难,所以我吐了......你的第二个和第三个变量的类型错误
-
我已经编辑了帖子
-
您将过时的 c-api 调用与 c++ api 混合在一起。如果您始终坚持使用 c++ api,并且避免使用所有 cvfunctions, CvMat IplImage*,那么您所有的问题都会消失
标签: visual-studio-2010 opencv image-processing