【发布时间】:2012-11-19 14:27:53
【问题描述】:
我正在尝试构建一个解决难题的应用程序(尝试开发图形算法),我不想一直手动输入示例输入。
编辑:我不是要开发游戏。我正在尝试构建一个玩“SpellSeeker”游戏的代理
假设我在屏幕上有一张图片(见附件),里面有数字,我知道盒子的位置,而且我有这些数字的确切图片。我想要做的只是告诉相应的盒子上哪个图像(数字)。
所以我想我需要实现
bool isImageInsideImage(Bitmap numberImage,Bitmap Portion_Of_ScreenCap) 或类似的东西。
我尝试过的是(使用AForge 库)
public static bool Contains(this Bitmap template, Bitmap bmp)
{
const Int32 divisor = 4;
const Int32 epsilon = 10;
ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching(0.9f);
TemplateMatch[] tm = etm.ProcessImage(
new ResizeNearestNeighbor(template.Width / divisor, template.Height / divisor).Apply(template),
new ResizeNearestNeighbor(bmp.Width / divisor, bmp.Height / divisor).Apply(bmp)
);
if (tm.Length == 1)
{
Rectangle tempRect = tm[0].Rectangle;
if (Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon
&&
Math.Abs(bmp.Height / divisor - tempRect.Height) < epsilon)
{
return true;
}
}
return false;
}
但在此图像中搜索黑点时返回 false。
我该如何实现?
【问题讨论】:
-
一些数独或井字游戏?
-
您在similar ground 上看到过其他问题吗?
-
这是一款名为“spellseeker”的游戏。但我只想构建算法来解决这样的问题并不重要。是的,实际上我在其他问题中找到了这个解决方案,但他们没有帮助我。原谅我的懒惰,但我真的认为应该有一个更简单的方法:)
-
+1 有趣的问题。 :-) 假设您锁定了原始拼图。所以你知道哪个块在哪里 - 就像它的整个网格点一样。当用户点击某些东西时,您不必查找图像,而是相应的点。您可以基于该点移动(复制/粘贴)子图像块。只是一个想法。
-
嗨 bonCodigo,我不知道我是否正确理解了您的评论,但我只想从图像中获取数字,而不是其他方式。这样我就可以初始化我的图形节点了。