opencv 轮廓排序
vector>contours ;
vectorhierarchy;
//找到轮廓
findContours(image, contours, hierarchy,CV_RETR_CCOMP ,CV_CHAIN_APPROX_SIMPLE );//查找轮廓//CV_RETR_EXTERNAL 外轮廓
//CV_CHAIN_APPROX_NONE //轮廓上所有点
//CV_RETR_CCOMP 所有轮廓
//CV_CHAIN_APPROX_SIMPLE //轮廓上部分点
//轮廓排序
static inline bool ContoursSortFun(vector contour1,vector contour2)
{
return (cv::contourArea(contour1) > cv::contourArea(contour2));
}
//调用轮廓排序的函数
std::sort(contours.begin(),contours.end(),ContoursSortFun);
//画轮廓
drawContours(resultcut, contours, 3, 0,CV_FILLED , 8, hierarchy, 0, Point());
//CV_FILLED//把内轮廓填充
//3,第3个轮廓
//0,黑色