問題描述
我目前有一個來自畫布上的手繪點的數組列表.我想知道是否有一個簡單的算法來檢測該形狀是否代表一個圓圈.我已經對此進行了一些研究,我指出的主要項目是霍夫變換或位圖圖像,但這兩者似乎都有點過頭了我需要它的頂部.任何指向算法或實現的指針都會非常有幫助.
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 have already researched this a little and the main items I am pointed at are either the Hough transform or having bitmap images but both of these seem a little over the top for what I need it for. Any pointers to algorithms or implementation would be very helpful.
提前感謝sansom,
thanks in advance sansoms,
推薦答案
如果你不知道用戶想要畫什么(例如,圓、橢圓、直線或矩形),你可以使用一些基本的優化算法來找到與手繪點最匹配的形狀.
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.
- 對于每個基本形狀(橢圓形、矩形、三角形、直線等),創建該形狀的隨機實例并測量誤差 w.r.t.給定點
- (單獨)優化每個形狀,直到獲得與給定點最匹配的橢圓、與點最匹配的矩形、最佳三角形等.
- 選擇誤差最小的形狀并繪制它
這篇關于來自點數組列表的java圓識別的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!