问题描述
我要检查绘制的形状是否与字母表中的字母匹配。这是一个用于学习的儿童应用程序。
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?
推荐答案
我没有适合您的示例代码,但是我想这就是我的方法。
I don't have any sample code for you but this is how I'd do this, I think.
您需要定义或获取描述每个字母形状的贝塞尔曲线-这将是一个实心字母的轮廓,而不仅仅是画字母形状的线。可能有一种方法可以从api获取此信息,从字形获取贝塞尔曲线路径,或者您可能必须自己设计它们。
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.
这是假设您要求用户绘制一个A,并且您正在检查该路径。如果您想找出他们绘制的内容而无需进行任何操作,则需要手写识别库,请尝试搜索其中的一个。
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.
这篇关于如何将屏幕上绘制的形状与字母进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!