OpenCV C++ cv::convexityDefects error

前端 未结 2 1287
北荒
北荒 2021-01-29 03:26
vector hull;
vector defects;
convexHull(Mat(largest),hull,false);
convexityDefects(largest,hull,defects);

*largest i

相关标签:
2条回答
  • 2021-01-29 04:15

    The second argument of convexityDefects has to be the type of vector<vector<int>, while yours is vector<Point>.

    0 讨论(0)
  • 2021-01-29 04:22

    for hull you should use a vector of vectors like this:

    vector<vector<Point>> hullsP( contours.size() );
    vector<vector<int> > hullsI(contours.size());
    

    and pass the "int" type to covexityDefects.like this :

    vector<vector<Vec4i>> convdefect(contours.size());
    
    for( int i = 0; i < contours.size(); i++ )
    { 
        convexHull( Mat(contours[i]), hullsP[i], false );
        convexHull( Mat(contours[i]), hullsI[i], false );       
        if(hullsI[i].size() > 3 )
            convexityDefects(contours[i],hullsI[i],convdefect[i]);
    }
    
    0 讨论(0)
提交回复
热议问题