opencv 轮廓的外围多边形提取或者删除最小最大轮廓

std::vector 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> &contours) { int cmin = 100; // 最小轮廓长度 int cmax = 1000; // 最大轮廓长度 vector>::const_iterator itc = contours.begin(); while(itc != contours.end()) { if((itc->size()) < cmin || (itc->size()) > cmax) { itc = contours.erase(itc); } else ++ itc; } }
原文地址:https://www.cnblogs.com/rjjhyj/p/11479899.html