java circle recognition from an arraylist of points

前端 未结 4 1715
情话喂你
情话喂你 2020-12-19 18:07

I currently have an arraylist of points from a freehand drawing on a canvas. I was wondering if there is a simple algorithm to detect if that shape represents a circle.I hav

4条回答
  •  伪装坚强ぢ
    2020-12-19 19:00

    If you do not know what the user wanted to draw (e.g., a circle, an ellipse, a line, or a rectangle), you could use some basic optimization algorithm to find the shape best matching the hand-drawn points.

    • for each basic shape (oval, rectangle, triangle, line, etc.), create a random instance of that shape and measure the error w.r.t. the given points
    • optimize each of the shapes (individually) until you have the oval best matching the given points, the rectangle best matching the points, the best triangle, etc.
    • pick the shape that has the lowest error and draw it

提交回复
热议问题