问题
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