模板匹配emgu

ぐ巨炮叔叔 提交于 2020-01-14 02:54:20
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;

namespace moments
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            Rectangle rec = new Rectangle();
            rec.X = 891;
            rec.Width = 110;
            rec.Height = 70;
            rec.Y = 675;


            Mat qq= CvInvoke.Imread("D:\\17.bmp");
            Mat qq1 =new Mat ( qq,rec);
            Mat qq3=new Mat ();
            Mat qq2 = CvInvoke.Imread("D:\\19.bmp");
          //  CvInvoke.Threshold(qq, qq, 95, 255,Emgu.CV.CvEnum.ThresholdType.BinaryInv);
         // Moments m=  CvInvoke.Moments(qq1);
          //  double[] hu = new double[7];
        //    hu = CvInvoke.HuMoments(m);
            CvInvoke.MatchTemplate(qq2, qq, qq3, Emgu.CV.CvEnum.TemplateMatchingType.CcorrNormed);
            Point max_loc = new Point();
            Point min_loc = new Point();
            double max = 0, min = 0;
            CvInvoke.MinMaxLoc(qq3, ref min, ref max, ref min_loc, ref max_loc);//获得极值信息
            Rectangle re = new Rectangle(max_loc, qq2.Size);
            CvInvoke.Rectangle(qq, re, new Emgu.CV.Structure.MCvScalar(0, 0, 255));
            imageBox1.Image = qq;

        }
    }
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!