我正在尝试构建一个应用程序来解决一个谜题(尝试开发图形算法),我不想一直手动输入示例输入。
编辑: 我不是在尝试构建一个游戏。我正在尝试构建一个代理程序来玩游戏“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。
我应该如何实现它?