如何将屏幕上绘制的形状与字母进行比较?
我想检查绘制的形状与字母表中的字母是否匹配。这是一款儿童学习应用程序。
当有人画出形状时,我如何检测它是正确的字母?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有任何示例代码供您使用,但我想这就是我的做法。
您需要定义或获取描述每个字母形状的贝塞尔路径 - 这将是实心字母的轮廓,而不仅仅是绘制字母形状的线条。可能有一种方法可以从 api 获取此信息,从字形获取贝塞尔路径,或者您可能必须自己设计它们。
然后,您需要缩放贝塞尔曲线路径,使其大小与屏幕上的绘图大致相同。
然后,检查绘制路径中有多少点属于标准字体字形。如果超过一定阈值,您就可以算作抽奖成功。
假设您已要求用户画一个 A,并且您正在检查该路径。如果您想在没有任何内容的情况下找出他们画的内容,您需要一个手写识别库,请尝试搜索其中之一。
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.