std::vector<cv::Point>  resultpoly;
cv::approxPolyDP(contours[0], resultpoly,4, true);//轮廓contours[0] ,resultpoly多边形的点集
cv::polylines(src, resultpoly, true, 150, 1);//画多边形的外轮廓
cv::imshow("detected polyLines", src);//显示多边形的外轮廓

//相关链接https://www.cnblogs.com/donaldlee2008/p/5230032.html
// 移除过小或过大的轮廓  
void getSizeContours(vector<vector<Point>> &contours)  
{  
    int cmin = 100;   // 最小轮廓长度  
    int cmax = 1000;   // 最大轮廓长度  
    vector<vector<Point>>::iterator itc = contours.begin();  
    while(itc != contours.end())  
    {  
        if((itc->size()) < cmin || (itc->size()) > cmax)  
        {  
            itc = contours.erase(itc);  
        }  
        else ++ itc;  
    }  
}

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-11-28
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案