無論如何可讓這件事情變得更快?因爲現在它就像是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