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; } }