OpenCV C ++ cv :: convexityDefects错误 [英] OpenCV C++ cv::convexityDefects error
问题描述
vector<Point> hull;
vector<Point> defects;
convexHull(Mat(largest),hull,false);
convexityDefects(largest,hull,defects);
* 最大是图像中我最大的轮廓
*largest is my largest contour in the image
但是凸性缺陷给了我这个错误断言失败(hull.checkVector(1,CV_32S)> 2)".有人请帮助我,我不想求助于使用C解决方案.
But the convexityDefects gives me this error "Assertion failed (hull.checkVector(1, CV_32S) > 2)". Someone please help me, I do not want to resort to using C solution.
已编辑
vector<int> hull;
vector<Point> defects;
convexHull(Mat(largest),hull,false);
vector<vector<int>> testhull;
testhull.push_back(hull);
convexityDefects(largest,testhull,defects);
在将其传递给凸性缺陷之前,我尝试使用类型vector<vector<int>>
进行制造,但是凸性缺陷仍然给我错误断言失败(ptnum> 3)..".
I tried making it with the type vector<vector<int>>
before passing it to convexityDefects but convexityDefects is still giving me error "Assertion failed (ptnum > 3)..".
推荐答案
convexityDefects
的第二个参数必须是vector<vector<int>
的类型,而您的是vector<Point>
.
The second argument of convexityDefects
has to be the type of vector<vector<int>
, while yours is vector<Point>
.
这篇关于OpenCV C ++ cv :: convexityDefects错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!