- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个关于颜色检测的问题。我有代码,但我想要不止一个结果。该代码很有名,但我想让程序给我带来所有结果,而不仅仅是一个结果。我希望我说清楚了。
不好意思我做了丢失的副本
private Boolean FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
{
try
{
for (int outerX = 0; outerX < bmpHaystack.Width - bmpNeedle.Width; outerX++)
{
for (int outerY = 0; outerY < bmpHaystack.Height - bmpNeedle.Height; outerY++)
{
for (int innerX = 0; innerX < bmpNeedle.Width; innerX++)
{
for (int innerY = 0; innerY < bmpNeedle.Height; innerY++)
{
Color cNeedle = bmpNeedle.GetPixel(innerX, innerY);
Color cHaystack = bmpHaystack.GetPixel(innerX + outerX, innerY + outerY);
if (cNeedle.R != cHaystack.R || cNeedle.G != cHaystack.G || cNeedle.B != cHaystack.B)
{
goto notFound;
}
}
}
location = new Point(outerX, outerY);
listBox1.Items.Add(location);
MessageBox.Show(location.ToString());
notFound:
continue;
}
}
}
catch (Exception)
{
}
location = Point.Empty;
return false;
}
最佳答案
I want to the program to bring me all the results not just one result
返回所有结果的列表。因此,您将修改您的方法以具有不同的返回类型:
public List<Point> FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
{
List<Point> results = new List<Point>();
for (int outerX = 0; outerX < bmpHaystack.Width - bmpNeedle.Width; outerX++)
{
for (int outerY = 0; outerY < bmpHaystack.Height - bmpNeedle.Height; outerY++)
{
for (int innerX = 0; innerX < bmpNeedle.Width; innerX++)
{
for (int innerY = 0; innerY < bmpNeedle.Height; innerY++)
{
Color cNeedle = bmpNeedle.GetPixel(innerX, innerY);
Color cHaystack = bmpHaystack.GetPixel(innerX + outerX, innerY + outerY);
if (cNeedle.R != cHaystack.R || cNeedle.G != cHaystack.G || cNeedle.B != cHaystack.B)
{
goto notFound;
}
}
}
location = new Point(outerX, outerY);
// collect the result
results.Add(location);
notFound:
continue;
}
}
// when you are finished looping return it
return results;
}
关于C#颜色检测多于一个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42506220/
我有以下型号:http://slexy.org/view/s20T8yOiKZ from mxutils.cms_services import generate_secid from django.
我遇到了一个问题..当我用我的程序运行 valgrind 时,我得到了以下输出,这让我很困惑: ==12919== HEAP SUMMARY: ==12919== in use at exit
我有一张产品销售表。每笔销售都有一个项目代码(例如序列号)和一个日期。 item_code | date a | 2013-01-01 a | 2013-01-18 b | 3013-02-10 c
是否可以定义一个不限于 1 个字符的分隔符?基于标题的示例,我想将我的分隔符定义为例如'#+#'。文本文件/行可以包含这两个字符,但您遇到特定子字符串/文本组合的可能性很小。 最佳答案 不可以,您不能
Produce a PDA to recognise the following language : the language of strings containing more a's than
我想做一个程序,想像这样生成一个 process -> n process -> n process 第二级可以使用多处理生成进程吗?使用 python 2.6 的 multiprocessinf 模
我对使用 CNN 进行图像识别非常陌生,目前使用 Keras(VGG 和 ResNet)中提供的几种标准(预训练)架构来执行图像分类任务。我想知道如何将输入 channel 的数量概括为 3 个以上(
我有一个 html 文档,当 URL 长度小于 30 个字符时,我想隐藏其中的一些 id(在本例中为 id="test")。 var test = document.getElementById('t
我有一个以 Qtreewidget(有 3 列)作为中央小部件的主窗口。我想保持第一列和第二列的大小固定,但第二列的大小应等于 qtreewidget 的大小减去其他两列的大小。既然主窗口(也就是树形
我的问题类似于this一。我想知道是否存在一个 PDA,它以随机顺序接受包含 a、b 和 c 的任何单词,其中 a 的总量高于 b 的总量并高于 c 的总量,例如单词“abcacba”将被接受。 最佳
我正在尝试使用准备好的 PDO 语句执行 while 循环,但我只希望它在有任何行时执行。目前我正在使用它,但它似乎缺少第一个结果,大概是因为它移动了指针。 正确的做法是什么? $stmt = $pd
1.实体(表)CurrentyEnitiy.java @Entity(tableName = "Corona") public class CurrentyEntity { @PrimaryKey(a
我是一名优秀的程序员,十分优秀!