无论如何可让这件事情变得更快?因为现在它就像是6秒钟的sourceImage,大小为1024x768,模板为50x50左右。这是使用AForge,如果有人知道其他更快,相当简单的方式,请提交。 我试图做的任务是在屏幕截图中找到较小的图像。最好快一点我的限制是1秒。我正在寻找的图像是一个红色的矩形简单的图像,截图更复杂。在另一个大图像内找到较小的图片并快速
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.5%)
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);
你可以发布一些exaples? – BlackBear 2012-02-25 12:14:09
图片的例子? – 2012-02-25 12:14:50
图片示例不能做:它说我需要超过10的声望才能做到这一点。我现在只有4个 – 2012-02-25 12:21:47