【精选】原创-EMGUCV的模板匹配与跟踪完成啦.docVIP

  • 4
  • 0
  • 约9.03千字
  • 约 11页
  • 2017-12-06 发布于贵州
  • 举报

【精选】原创-EMGUCV的模板匹配与跟踪完成啦.doc

【精选】原创-EMGUCV的模板匹配与跟踪完成啦

原创-EMGUCV的模板匹配与跟踪完成啦!?兄弟们好! ??经过很多天的努力学习,我的EMGUCV的模板匹配完成了,用实际的摄像头取图象,再存为模板后,就能实现物体跟踪,还能进行相机上马达进行位置确定。好玩吧!弄两幅图来看下。 这是匹配的,还能过行坐标二次定位。 坐标二次定位的 这是跟踪的 以下为代码,只有自己写的部分,由软件生成的部分没有帖上 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.IO; using System.Drawing.Imaging; using Emgu.CV; using Emgu.CV.Structure; using Emgu.CV.CvEnum; using Emgu.CV.Util; using Emgu.CV.UI; using Emgu.CV.VideoSurveillance; using Emgu.Util; using Emgu.Util.TypeEnum; using Emgu.CV.GPU; namespace 模板匹配 { ? ? public partial class Form1 : Form ? ? { ? ? ? ? public ImageBgr, byte src; ? ? ? ? public ImageBgr, byte tempsrc; ? ? ? ? public Form1() ? ? ? ? { ? ? ? ? ? ? InitializeComponent(); ? ? ? ? } ? ? ? ? private void button1_Click(object sender, EventArgs e) ? ? ? ? { ? ? ? ? ? ? OpenFileDialog of = new OpenFileDialog(); ? ? ? ? ? ? of.Filter = (jpg)|*.jpg; ? ? ? ? ? ? if (of.ShowDialog ()== DialogResult.OK) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ImageBgr, byte imsrc = new ImageBgr, byte(of.FileName); ? ? ? ? ? ? ? ? imageBox2.Image = imsrc; ? ? ? ? ? ? ? ? src = imsrc; ? ? ? ? ? ? ? ? imageBox1.Image = null; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? private void button2_Click(object sender, EventArgs e) ? ? ? ? { ? ? ? ? ? ? if (src != null) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ImageBgr, byte imgsrc = src.Clone();//不可直接将src符值给新建图象,它传的只是一个地址,不是数据,要先考贝后才能不再引响原图像 ? ? ? ? ? ? ? ? ImageGray, byte imggray = imgsrc.ConvertGray, byte(); ? ? ? ? ? ? ? ? ImageGray, byte imgthread = imggray.ThresholdBinary(new Gray(60), new Gray(255)); ? ? ? ? ? ? ? ? ImageGray, byte imgcanny = imgthread.Canny(130,255); ? ? ? ? ? ? ? ? //ContourPoint contour = imgcanny.FindContours();//这个函数用来找中间的轮廓的每一个点,是一个数组点,很多个才能组成一个圆。 ? ? ? ? ? ? ? ? CircleF[] cf = imgthread.HoughCircles(new Gray(130), new Gray(255), 10, 1, 1, 400)[0]; ? ? ? ? ? ? ? ? MCvFont mf = new MCvFont(FONT.CV_FONT_HERSH

文档评论(0)

1亿VIP精品文档

相关文档