How to compare a shape drawn on the screen to a letter?

折月煮酒 提交于 2019-12-22 08:19:06

问题


I want to check the drawn shape matches a letter from the alphabet. It's a kids app for learning.

When any one draw the shape then how can i detect it's a correct letter?


回答1:


I don't have any sample code for you but this is how I'd do this, I think.

You need to define or get a bezier path describing the shape of each letter - this would be an outline of a solid letter, not just a line drawing the letter shape. There may be a way to get this from the api, obtaining a bezier path from a glyph, or you may have to design them yourself.

You then need to scale the bezier path so it is roughly the same size as the drawing on the screen.

Then, check how many of the points in the drawn path fall within your standard font glyph. If its over a certain threshold, you can count that as a successful draw.

This is assuming you've asked the user to draw an A and you are checking against that one path. If you're trying to find out what theyve drawn without anything to go on, you need a handwriting recognition library, try searching for one of those.



来源:https://stackoverflow.com/questions/7990774/how-to-compare-a-shape-drawn-on-the-screen-to-a-letter

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