OpenCV中findContours详解

来源:互联网 发布:淘宝号被别人实名认证 编辑:程序博客网 时间:2024/06/01 07:42

//寻找轮廓,参见http://blog.sina.com.cn/s/blog_7155fb1a0101a90h.html

void findContours(InputOutputArray image,  //二值化单通道图片,会因为输出而改变//存储轮廓,contours[i]表示第i条轮廓OutputArrayOfArrays contours,//hierarchy[i][j],j从0~3,分别表示第i条轮廓的前、后、父、内嵌轮廓OutputArray hierarchy,   /*轮廓的检索方法,http://blog.csdn.net/lu597203933/article/details/14489225CV_RETR_CCOMP:按照白色外轮廓和白色内轮廓(孔)分别保存所有轮廓,轮廓的顺序满足从外到里、从下往上、从小到大、从右往左,范例轮廓的编号
CV_RETR_LIST:按照双向链表存储所有轮廓,轮廓的顺序满足从里到外,从从下往上、从小到大、从右到左
CV_RETR_EXTERNAL:仅检测最外围轮廓
CV_RETR_TREE:按照树建立存储所有轮廓,轮廓的顺序满足从外到里、从下往上、从小到大、从右往左
*/int mode,/*轮廓的存储方法CV_CHAIN_APPROX_SIMPLE:压缩水平方向,垂直方向,对角线方向的元素,即一条直线仅用两个点存储。CV_CHAIN_APPROX_NONE:存储所有的点,占用空间较大CV_CHAIN_APPROX_TC89_L1,CV_CHAIN_APPROX_TC89_KCOS使用teh-Chinlchain 近似算法*/int method, Point offset=Point());

//画椭圆

void ellipse(CV_IN_OUT Mat& img,Point center,              //椭圆中心Size axes,            //Size(长轴,短轴)double angle,     //偏转角度,单位°,顺时针double startAngle,  doubleendAngle,            //起始角度和终点角度const Scalar& color,  //依次为B、G、Rint thickness=1,         //=-1或CV_FILLED时,为填充模式int lineType=8,          // 线型,http://blog.sina.com.cn/s/blog_4ffc4c300102w825.htmlint shift=0);

//得到轮廓的大小

double contourArea( InputArraycontour, bool oriented=false );

//返回轮廓的外包括矩形

Rect boundingRect( InputArray points);

//返回包括轮廓的最小矩形

RotatedRect minAreaRect( InputArraypoints );

//返回包括轮廓的最小圆

void minEnclosingCircle( InputArraypoints, CV_OUT Point2f& center, CV_OUT float& radius );

//返回包括轮廓的最小椭圆

RotatedRect fitEllipse( InputArraypoints );

//画出轮廓线

void drawContours( InputOutputArrayimage,InputArrayOfArrays contours,//画出第几个轮廓,=-1时,画出所有轮廓                    int contourIdx,const Scalar& color,int thickness=1, int lineType=8,//由findContours得到的hierarchyInputArray hierarchy=noArray(),//当存储方法服从CV_RETR_TREE分布时,显示深度为maxLevel以内的轮廓int maxLevel=INT_MAX,//坐标的偏置Point offset=Point() );


0 0
原创粉丝点击