問題描述
我目前有一個(gè)來自畫布上的手繪點(diǎn)的數(shù)組列表.我想知道是否有一個(gè)簡單的算法來檢測該形狀是否代表一個(gè)圓圈.我已經(jīng)對此進(jìn)行了一些研究,我指出的主要項(xiàng)目是霍夫變換或位圖圖像,但這兩者似乎都有點(diǎn)過頭了我需要它的頂部.任何指向算法或?qū)崿F(xiàn)的指針都會(huì)非常有幫助.
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,
推薦答案
如果你不知道用戶想要畫什么(例如,圓、橢圓、直線或矩形),你可以使用一些基本的優(yōu)化算法來找到與手繪點(diǎn)最匹配的形狀.
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.
- 對于每個(gè)基本形狀(橢圓形、矩形、三角形、直線等),創(chuàng)建該形狀的隨機(jī)實(shí)例并測量誤差 w.r.t.給定點(diǎn)
- (單獨(dú))優(yōu)化每個(gè)形狀,直到獲得與給定點(diǎn)最匹配的橢圓、與點(diǎn)最匹配的矩形、最佳三角形等.
- 選擇誤差最小的形狀并繪制它
這篇關(guān)于來自點(diǎn)數(shù)組列表的java圓識別的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!