这是一个快速的示例,但是它花的时间很慢,大约需要4-6秒钟,但是它确实满足您的要求,我知道此帖子很旧,但是如果最近有其他人访问此帖子,则可以查找此东西。框架谷歌它,并安装它在您的项目中包括AForge命名空间,就是这样,它会找到另一个,然后给出坐标。
System.Drawing.Bitmap sourceImage = (Bitmap)Bitmap.FromFile(@"C:\SavedBMPs\1.jpg");
System.Drawing.Bitmap template = (Bitmap)Bitmap.FromFile(@"C:\SavedBMPs\2.jpg");
// create template matching algorithm's instance
// (set similarity threshold to 92.1%)
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.921f);
// find all matchings with specified above similarity
TemplateMatch[] matchings = tm.ProcessImage(sourceImage, template);
// highlight found matchings
BitmapData data = sourceImage.LockBits(
new Rectangle(0, 0, sourceImage.Width, sourceImage.Height),
ImageLockMode.ReadWrite, sourceImage.PixelFormat);
foreach (TemplateMatch m in matchings)
{
Drawing.Rectangle(data, m.Rectangle, Color.White);
MessageBox.Show(m.Rectangle.Location.ToString());
// do something else with matching
}
sourceImage.UnlockBits(data);
0
我有2张bmp图片。 ImageA是屏幕截图(示例),ImageB是其子集。例如说一个图标。
我想在ImageA中找到ImageB的X,Y坐标(如果存在)。
知道我会怎么做吗?