为什么opencv的Findcontour不同表现在Emgu C#? [英] Why is Opencv Findcontour behaving differently in Emgu c#?

查看:265
本文介绍了为什么opencv的Findcontour不同表现在Emgu C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜在OpenCV的C +方法 Findcontours 返回数组的层次结构,并获取洞我可以得到层次的界限。
我怎样才能在emgu品种获得这些边界请任何帮助吗?
我怎么才能找到emgu CV孔?

Hi in opencv c+ method Findcontours return the array hierarchy and to get the boundaries of the hole I can get the hierarchy . how can i get these boundaries in emgu cv please any help? how can i find holes in emgu cv?

推荐答案

您可以通过使用获得Emgucv轮廓层次结构中此以下。代码

You can get the Contour hierarchy in Emgucv by using this following code.

Image<Bgr, byte> Img_Result_Bgr = Img_Source_Bgr.Copy();
Image<Gray, byte> Img_Org_Gray = Img_Source_Bgr.Convert<Gray, byte>();
Image<Gray, byte> Img_CannyEdge_Gray = new Image<Gray, byte>(Img_Source_Bgr.Width,Img_Source_Bgr.Height);

Img_CannyEdge_Gray = Img_Org_Gray.Canny(10, 50);
Img_Org_Gray.Dispose();

Random Rnd = new Random();

#region Finding Contours
using (MemStorage storage = new MemStorage()) //allocate storage for contour approximation
    for (Contour<Point> contours = Img_CannyEdge_Gray.FindContours(); contours != null; contours = contours.HNext)
    {
        Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);//if you want to Approximate the contours into a polygon play with this function().

        if (contours.Area > 100) //only consider contours with area greater than 100
        {
            Img_Result_Bgr.Draw(contours, new Bgr(Rnd.Next(255),Rnd.Next(255),Rnd.Next(255)), 2);
        }
    }
#endregion
Img_CannyEdge_Gray.Dispose();

imageBox1.Image = Img_Result_Bgr; 

有关进一步参考使用本的在线辅导!
下面是这段代码的输出。
http://s18.postimg.org/511xwpm15/Forum_Contour.jpg

For further Reference use this Online Tutor! Here is the output of this code. http://s18.postimg.org/511xwpm15/Forum_Contour.jpg

这篇关于为什么opencv的Findcontour不同表现在Emgu C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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