你好,opencv c++ 方法Findcontours
返回数组层次结构并获取孔的边界,我可以获取层次结构。
我怎样才能在 emgu 简历中得到这些边界请帮忙?
我怎样才能找到 emgu 简历中的漏洞?
您可以使用以下代码获取 Emgucv 中的轮廓层次结构。
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://www.emgu.com/wiki/index.php/Tutorial这是该代码的输出。http://s18.postimg.org/511xwpm15/Forum_Contour.jpg http://s18.postimg.org/511xwpm15/Forum_Contour.jpg
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)