首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EmguCV -如何找到List<Contour<Point>>坐标?

EmguCV -如何找到List<Contour<Point>>坐标?
EN

Stack Overflow用户
提问于 2014-06-30 02:13:00
回答 2查看 2.8K关注 0票数 0

我只想知道如何从轮廓点列表中提取一些元素。

基本上,我有这样的想法:

代码语言:javascript
复制
List<Contour<Point>> contoursList = new List<Contour<Point>>;
contourList.Add(contours); //that contours variable is a Contour<Point> that i receive in a .FindContour method.

然后,我需要选择/提取/这个列表中的任何一个特定元素,并找到它的坐标。那么我该怎么做呢?

还有,有什么想法吗?

EN

回答 2

Stack Overflow用户

发布于 2014-06-30 18:55:24

你推荐过this post了吗?

使用特性过滤器,如面积、等高线长度和每条等高线的中心来过滤所需的等高线坐标。

票数 0
EN

Stack Overflow用户

发布于 2014-07-12 15:46:54

下面是你应该做的:

  1. 首先,创建等值线变量
  2. 在枚举等值线时,执行FindCountour()方法时,将当前等值线推入您在1中声明的变量。
  3. 根据您的条件选择特定元素

参见下面的示例代码:

代码语言:javascript
复制
                //variable to hold the contour
                Contour<Point> contours = null;

                for (var contour = binaryImage.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
                RETR_TYPE.CV_RETR_CCOMP, mem);
                contour != null;
                contour = contour.HNext)
                {
                    if (contours == null)
                    {
                        //this is to ensure contours is not null
                        contours = contour;
                    }

                    //push/add the sequence of points to contours
                    contours.PushMulti(contour.ToArray(), BACK_OR_FRONT.BACK);
                }

                //do what you want with it
                var ch = contours.GetConvexHull(ORIENTATION.CV_CLOCKWISE, mem);

                //for example, convert these points to type PointF
                PointF[] pointfs = Array.ConvertAll(contours.ToArray(), input => new PointF(input.X, input.Y));

                //or detect the bounding rectangle
                var roi = PointCollection.BoundingRectangle(pointfs);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24478831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档