查找中的另一个大的和快速的较小的图像 [英] Find a smaller image within another big one and fast

查看:323
本文介绍了查找中的另一个大的和快速的较小的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正做这个东西跑得更快?堂妹现在它就像在sourceImage 6秒1024×768的尺寸和模板50×50左右。这是使用AForge,如果有谁知道其他更快,而简单的方法,请提交。
中的任务,我想要做的是找到一个截图中的一个较小的图像。最好快我的极限是1秒。我在找的图片是一个红色的矩形简单的图像,然后将截图更为复杂。

  System.Drawing.Bitmap sourceImage =(位图)Bitmap.FromFile(@C:\SavedBMPs\1.jpg ); 
System.Drawing.Bitmap模板=(位图)Bitmap.FromFile(@C:\SavedBMPs\2.jpg);
//创建模板匹配算法的实例,
//(设置相似性阈值92.5%)

ExhaustiveTemplateMatching TM =新ExhaustiveTemplateMatching(0.921f);
//找到所有的匹配上面相似

TemplateMatch [] =的匹配tm.ProcessImage(sourceImage,模板)中指定;
//亮点发现的匹配

的BitmapData数据= sourceImage.LockBits(
新的Rectangle(0,0,sourceImage.Width,sourceImage.Height),
ImageLockMode。读写,sourceImage.PixelFormat);
的foreach(在的匹配TemplateMatch米)
{

Drawing.Rectangle(数据,m.Rectangle,Color.White);

MessageBox.Show(m.Rectangle.Location.ToString());
//做别的事情与匹配
}
sourceImage.UnlockBits(数据);


解决方案

http://opencv.willowgarage.com/wiki/FastMatchTemplate - 在这里你可以找到加快使用两个步骤模板匹配有趣的想法,第一次尝试匹配下采样图像,发现匹配原有的较小的搜索区域。

$ b当
$ b

另外还有OpenCV的实施matchTemplate函数模板匹配。此功能移植到GPU能得到显著加快。



请参阅以下



http://opencv.willowgarage.com/documentation/cpp/object_detection.html - matchTemplate功能。
http://opencv.willowgarage.com/wiki/OpenCV_GPU - 关于OpenCV的功能移植到GPU。


Anyway to make this thing go faster ? coz right now it's like 6 seconds on the sourceImage the size of 1024x768 and template 50x50 around. This is using AForge, if anyone knows other faster and rather simple ways please submit. The task i'm trying to do is to find a smaller image within a screenshot. And preferably fast my limit is 1 second. The image i'm looking for is a red rectangle simple image and the screenshot is more complex.

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);

解决方案

http://opencv.willowgarage.com/wiki/FastMatchTemplate - here you can find interesting idea for speeding up the template matching using two steps, first try to match downsampled images and when found match the original ones with smaller search region.

Also there is opencv implementation of template matching in matchTemplate function. This function is ported to GPU which can get significant speed up.

See the following

http://opencv.willowgarage.com/documentation/cpp/object_detection.html - matchTemplate function. http://opencv.willowgarage.com/wiki/OpenCV_GPU - about OpenCV functionality ported to GPU.

这篇关于查找中的另一个大的和快速的较小的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆