【OpenCV】cvFindContours参数详解
2016-04-15 16:33
696 查看
其参数列表为:
CvArr* image: 待提取轮廓的图像
(注意:该图像是经过二值化后的图像,二值化可以使用cvThreshold()函数)
CvMemStorage* storage: 存储空间
CvSeq** first_contour:轮廓序列
Int mode: 模式默认情况下是CV_RETR_LIST,共有4种模式:
CV_RETR_EXTERNAL: 只提取最最最外面的轮廓
CV_RETR_LIST: 把所有轮廓都保存下来,放在一张列表里,可以用下标来访问,但是不会计算轮廓之间的层次关系,也就是说并不知道轮廓之间是什么关系
CV_RETR_CCOMP: gives contours and organises them into outer and inner contours. Every contour is either the outline of an object, or the outline of an object inside another object (i.e. hole).
The hierarchy is adjusted accordingly. This can be useful if (say) you want to find all holes.(感觉英文的理解起来比很多博客上给的中文理解要好)
CV_RETR_TREE: calculates the full hierarchy of the contours. So you can say that object1 is nested 4 levels deep within object2 and object3 is also nested 4 levels deep.
使用CV_RETR_CCOMP时,可以用cvDrawContours()来绘制轮廓,可以看到给外部轮廓和hole的轮廓用不同颜色,就一目了然了。
以下是cvThreshold, cvFindContours和cvDrawContours的代码:
CvArr* image: 待提取轮廓的图像
(注意:该图像是经过二值化后的图像,二值化可以使用cvThreshold()函数)
CvMemStorage* storage: 存储空间
CvSeq** first_contour:轮廓序列
Int mode: 模式默认情况下是CV_RETR_LIST,共有4种模式:
CV_RETR_EXTERNAL: 只提取最最最外面的轮廓
CV_RETR_LIST: 把所有轮廓都保存下来,放在一张列表里,可以用下标来访问,但是不会计算轮廓之间的层次关系,也就是说并不知道轮廓之间是什么关系
CV_RETR_CCOMP: gives contours and organises them into outer and inner contours. Every contour is either the outline of an object, or the outline of an object inside another object (i.e. hole).
The hierarchy is adjusted accordingly. This can be useful if (say) you want to find all holes.(感觉英文的理解起来比很多博客上给的中文理解要好)
CV_RETR_TREE: calculates the full hierarchy of the contours. So you can say that object1 is nested 4 levels deep within object2 and object3 is also nested 4 levels deep.
使用CV_RETR_CCOMP时,可以用cvDrawContours()来绘制轮廓,可以看到给外部轮廓和hole的轮廓用不同颜色,就一目了然了。
以下是cvThreshold, cvFindContours和cvDrawContours的代码:
CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst, double threshold, double max_value, int threshold_type );
/* Retrieves outer and optionally inner boundaries of white (non-zero) connected components in the black (zero) background */ CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour, int header_size CV_DEFAULT(sizeof(CvContour)), int mode CV_DEFAULT(CV_RETR_LIST), int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE), CvPoint offset CV_DEFAULT(cvPoint(0,0)));
/* Draws contour outlines or filled interiors on the image */ CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, CvScalar external_color, CvScalar hole_color, int max_level, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), CvPoint offset CV_DEFAULT(cvPoint(0,0)));
相关文章推荐
- 嵌入式linux内核制作流程
- opencv学习之路
- tomcat 一个项目在本机和办公室以外电脑服务器上搭建出现乱码问题
- hadoop
- DOM之属性(attribute)和自定义对象属性(property)
- 一台服务器搭载两个tomcat项目
- tomcat运行web项目,不能访问动态地址,也就是controller
- 分布式架构高可用架构篇_01_zookeeper集群的安装、配置、高可用测试
- centos Linux 常用命令汇总
- shell条件-循环-分支-函数
- 常用的网站
- Linux下安装使用 mysql connector/C++
- shell mysql命令 传参数
- System.arraycopy
- CentOS6.5上hive安装过程与常见错误调试
- 【OpenCV】goodFeaturesToTrack_Demo详解
- tomcat7.0配置CORS(跨域资源共享)
- linux 内核 的 I/O 模型 (总结)
- Docker Dockerfile详解
- Docker Dockerfile详解