在OpenCV中找到该组点的轮廓 [英] Find contour of the set of points in OpenCV

查看:508
本文介绍了在OpenCV中找到该组点的轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过来自OpenCV的MSER检测来查找图像上的对象。但函数 cvExtractMSER 不返回轮廓,而是设置点( CvSeq ),创建图:

 (1,4),(2,3),(2,4),(3,2),(3,3), 3,4),(4,1),(4,2),(4,3),(4,4),... 



但我只需要轮廓点:

 (1,4) ),(8,1),(4,1)



我如何找到这个轮廓?



我认为,最简单(但不是最快)的方式是:




  • 用所有点绘制b / w图像(如何点对点?)

  • 使用 findContours

    > findContours()中的一个选项是传递一个参数,该参数将从中删除。
  • 除直线水平,垂直或对角线上的端点之外的所有点。如果你创建一个图像并绘制你列出的点,findContours()可以为你做其余的工作。


    CV_CHAIN_APPROX_SIMPLE压缩水平,垂直和对角线段,只留下它们的端点。例如,一个右上角的矩形轮廓用4个点编码。


    http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours


    I try to find objects on image by MSER-detection from OpenCV. But function cvExtractMSER return not contours, but set of points (CvSeq), that create figure:

    (1, 4), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4), ...
    

    But I needs only points of contour:

    (1, 4), (8, 4), (8, 1), (4, 1)
    

    How I can find this contour?

    I think, that simplest (but not fastest) way is:

    • draw b/w image with all points (how? point-by-point?)
    • use findContours for find contours on new image

    解决方案

    One of the options in findContours() is to pass a parameter that will remove all points except end points on a straight horizontal, vertical, or diagonal line. If you create an image and draw the points you've listed, then findContours() can do the rest of the work for you.

    CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an up-right rectangular contour is encoded with 4 points.

    http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours

    这篇关于在OpenCV中找到该组点的轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆