简体   繁体   中英

2D Shape recognition and resolving algorithm

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM