无论如何要让这件事变得更快?现在,它就像source
Image上的6秒,大小为1024×768,模板为50×50左右.这是使用AForge,如果有人知道其他更快更简单的方法请提交.
我要做的任务是在屏幕截图中找到一个较小的图像.最好快我的限制是1秒.我正在寻找的图像是一个红色矩形简单图像,截图更复杂.
我要做的任务是在屏幕截图中找到一个较小的图像.最好快我的限制是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,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);
解决方法
http://opencv.willowgarage.com/wiki/FastMatchTemplate – 在这里你可以找到有趣的想法,使用两个步骤加速模板匹配,首先尝试匹配下采样图像,当找到匹配原始的较小的搜索区域.
在matchTemplate函数中还有opencv实现模板匹配.此功能移植到GPU,可以显着加快速度.
请参阅以下内容
http://opencv.willowgarage.com/documentation/cpp/object_detection.html – matchTemplate函数.
http://opencv.willowgarage.com/wiki/OpenCV_GPU – 关于移植到GPU的OpenCV功能.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。