我试图找到使用轮廓函数的连接组件,但是我发现findContours函数有错误。我使用OpenCV的2.4.7和Visual Studio 2010在findContours函数中使用轮廓错误查找连接组件
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
没有看到你的代码的其余部分,这是困难的这样的IM spitballing ... 你的第二个和第三个变量是错误的类型 – GPPK
我已经编辑 – user3108024
你混合过时C-API与C调用的帖子++ API。你所有的问题都会消失,如果你始终坚持使用C++ api,并且避免所有的cv *函数,那么CvMat * IplImage * – berak