2D Shape recognition and resolving algorithm

那年仲夏 提交于 2019-12-24 07:00:15

问题


I'm looking for an algorithm for detecting simple shapes as rectangles, triangles, squares and circles, from a given set of (x,y) points. I'm also looking for a way of, once detected, transform the path to a more clean shape.

I've scrambled the internet but haven't found any "simple" approaches. Almost all of them are way to advanced for my simple implementation.

Thanks in advance.


回答1:


On detection:

There are most likely no simple general approaches for classifying any set of points into a shape. However, there are a few basic functions that you could probably build that will be useful for classifying many of the shapes. For instance:

  1. Whether or not the points form a straight line
  2. Whether or not the points form a convex/concave polygon (useful for disqualifying points from matching certain shapes)
  3. Finding center of points and finding distance to center from each point
  4. Whether or not two points share a common axis

With the above functions, you should be able to write some basic logic for classifying several of the shapes.



来源:https://stackoverflow.com/questions/15811192/2d-shape-recognition-and-resolving-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!