0

我想知道如何(如果有的话)在给定一组鼠标点击的 X、Y 坐标的情况下确定形状?

我们在这里处理了许多问题,可能存在与形状无关的点击(坐标)。下面是一个例子:http ://tinypic.com/view.php?pic=286tlkx&s=6 绿点代表鼠标点击,搜索的是一个高度/宽度至少为x,高度/最多为y的正方形宽度和折衷四个点,红线表示找到的形状。我希望能够找到一些基本形状,例如正方形、矩形、三角形和理想的圆形。

我听说最小二乘对我有帮助,但我不清楚这对我有什么帮助。我正在使用 C#,示例非常受欢迎:)

4

1 回答 1

0

You can create detectors for each shape you want to support. These detectors will tell, if a set of points form the shape.

So for example you would pass 4 points to the quad detector and it returns, if the 4 points are aligned in a quad or not. The quad detector could work like this:

  • for each point
    • find the closest neighbour point
    • compute the inner angle
    • compute the distance to the neighbours
  • if all inner angles are 90° +- some threshold -> ok
  • if all distances are equal +- some threshold (percentage) -> ok
  • otherwise it is no quad.

A naive way to use these detectors is to pass every subset of points to them. If you have enough time, then this is the easiest way. If you want to achieve some performance, you can select the points to pass a bit smarter.

E.g. if quads are always axis aligned, you can start at any point, go right until you hit another point (again with some thresold), go down, go left.

Those are just some thoughts that might help you further. I can imagine that there are algorithms in AI that can solve this problem in a more pragmatic way, maybe neural networks.

于 2012-10-24T21:16:47.743 回答