小编cab*_*nal的帖子

凸性缺陷C++ OpenCv

如果你能帮我解决这个问题,我将不胜感激:)

关于这个问题cvConvexityDefects在OpenCV 2.X/C++中?, 我也有同样的问题.OpenCV C++包装器没有出现在C版本中的函数cvConvexityDefects,所以我尝试编写自己的版本.

部分代码是(请注意,countour和hull都是vector <Point>,单独计算:

CvSeq* contourPoints;
CvSeq* hullPoints;
CvSeq* defects;
CvMemStorage* storage;
CvMemStorage* strDefects;
CvMemStorage* contourStr;
CvMemStorage* hullStr;
CvConvexityDefect *defectArray = 0;

strDefects = cvCreateMemStorage();
defects = cvCreateSeq( CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq),sizeof(CvPoint), strDefects );

//We start converting vector<Point> resulting from findContours
contourStr = cvCreateMemStorage();
contourPoints = cvCreateSeq(CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), contourStr);
printf("Metiendo valores\n");
for(int i=0; i<(int)contour.size(); i++) {
    CvPoint cp = {contour[i].x,  contour[i].y};
    cvSeqPush(contourPoints, &cp);
}
//Now, the hull points obtained from convexHull c++
hullStr = cvCreateMemStorage(0);
hullPoints …
Run Code Online (Sandbox Code Playgroud)

c++ opencv defects convex-hull

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

convex-hull ×1

defects ×1

opencv ×1