Calculating convexityDefects using OpenCV 2.4 in c++

后端 未结 4 1730
时光取名叫无心
时光取名叫无心 2020-11-30 12:21

I\'m using OpenCV 2.4 to calculate the convex hull of a image.

I\'m also doing some processing to remove some noise from the image, which is not really relevant to

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 12:42

    From openCV wiki :

    Finds the convexity defects of a contour.

    So you should include it in your loop.

    std::vector defects; 
    vector >hull( contours.size() );
    
    for (int i = 0; i < contours.size(); i++)
    {  
        convexHull( contours[i], hull[i], false );
        convexityDefects(contours[i], hull[i], defects[i]);
    }
    

    Also, as you mentioned, in wiki is said:

    hull – Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the hull elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, hull elements are the convex hull points themselves.

提交回复
热议问题