【发布时间】:2014-01-22 20:29:19
【问题描述】:
我的论文是“多项选择考试检查器”,我对如何处理我的问题有一个大问题。我在这里得到了一张图片(特别是位图),所以你可以看到:
这是带有检测框的图像,我将对此进行描述:
- 这是一份试卷,1-50 道题。每个数字都有一个对应的方框(数字右侧,作为答案的容器)
- 此图片只是一个示例,检测到的框数可能会有所不同。我的估计是它包含 150-200 个检测到的框。
- 每个检测框都存储在一个 List(MCvBOX2D) 中,其中包含 检测框的大小、中心等
- 我将这些中心坐标转移到一个新列表中 List(PointF) center;
- 图像中的每个框可能有 3-5 个检测框。如您所见,图像中的每个框中都有多个检测框。
- 我按升序对所有检测到的框进行了排序,所以我会知道哪个可能是 number1、number2 等等..
这是我的一些代码,其中包含盒子的排序。
List<PointF> center = new List<PointF>();
List<PointF> centernew = new List<PointF>();
foreach (MCvBox2D box in lstRectangles)
{
// this code transfers every center-coordinates of detected boxes
// to a new list which is center
center.Add(new PointF(box.center.X, box.center.Y));
}
// and this one sorts the coordinates in ascending order.
centernew = center.OrderBy(p => p.Y).ThenBy(p => p.X).ToList();
-
我已经完成了排序部分,现在我的问题是,由于图像中的每个盒子中检测到很多盒子,我想group sortedlist 中心坐标,所以我可以消除其他检测框,每个数字只得到一个检测框。
-
我知道这很难理解,所以我会解释更多。
假设我的 检测框排序列表 包含前五个中心坐标,它们是:
假设这是图像第一个框的每个检测框的中心坐标。
center[0] = [ 45.39, 47.6]
center[1] = [ 65.39, 47.6]
center[2] = [ 45.40, 47.10]
center[3] = [ 65.45, 47.25]
center[4] = [ 46.01, 47.50]
and the 2nd are:
center[5] = [ 200.39, 47.2]
center[6] = [ 45.39, 47.2]
center[7] = [ 45.39, 47.3]
center[8] = [ 45.39, 47.55]
- 我的目标是在列表中组织所有已排序的检测框,我必须能够将所有与另一个中心值接近的中心坐标分组,特别是它们的 Y 坐标。
【问题讨论】:
-
包含 9 个项目的示例列表的输出应该是什么?
-
我的输出应该只有 50 个检测到的框,即 50 个中心坐标。第 1 组和第 2 组坐标是相似但不精确的坐标,它们是检测到某个框的框的中心坐标。
标签: c# list coordinates points