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;
}
}
}
来源:CSDN
作者:xutingjie168
链接:https://blog.csdn.net/qq_36786800/article/details/103758037