在 iPhone 上绘图
我正在尝试为儿童开发一款 iPhone 应用程序,该应用程序能够通过触摸在屏幕上绘制字符,我想知道如何将绘制的字符与字母表的良好字符相匹配。我将如何比较两种形状(绘图和现有) 有什么想法吗? 一些代码?
I am trying to develop an iPhone application for children which will be able to draw characters on screen with touch and I want to know how to match the character drawn with good character of the alphabet. How will i compare the two shapes (drawing and existing)
Any idea??
some code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 GLGestureRecognizer 您可以创建一个目录,它将根据“字母表”计算输入点数组之间的度量“你预先定义。
Using GLGestureRecognizer you can create a catalogue and it will compute a metric between an input point array against an "alphabet" you predefine.
哇,这听起来是一项艰巨的任务。我想到的一种可能性是使用支持向量机。
1.) 生成绘图的图像,并通过将矢量附加到用户绘制的路径来“矢量化”它。
2.) 您需要支持向量来进行比较。我要做的是实施一个“培训应用程序”。让一些孩子画画(例如 10 次 A,10 次 B,等等……),将向量放入数据库中并将它们用作支持向量。
3.) 您需要一个评级算法,通过将用户绘图与支持向量进行比较来对用户绘图进行评级(这可能是其中最有趣的部分)。我可以考虑测量支持向量起点和终点到绘制向量的距离。距离最近的 svm 就是你取的字母。然后,您可能会引入一个距离,即“边界”,并将此边界之上的所有用户绘图视为无法识别。
第二种方法可能是使用字母生成图像(例如白色背景和黑色字母(非抗锯齿))。您再次生成用户绘图的图像,并将其大小调整为要比较的图像,尝试准确地“重叠”它。然后计算两个图像中匹配的黑色像素,并取出最匹配的字母。
但是,由于我实现了类似的东西,我可以看出 svm 方法更令人满意,因为如果结果不够好,您可以添加支持向量。精髓肯定是您的评级算法。
无论如何,听起来像是几周的工作。
编辑:由于这是一个有趣的领域,我做了一些研究并发现了一篇关于手写识别的论文。看看这个:http://risujin.org/cellwriter/。它基本上描述了我提到的支持向量机方法,并提供了一些可能对您有帮助的算法。
Wow, this sounds like a tough task. One possibility that comes to my mind would be to use a support vector machine.
1.) Generate an image of the drawing and "vectorize" it by attaching vectors to the path the user has drawn.
2.) You need support vectors to compare. What i would do is, implement a "training application". Let some kids draw (eg. 10 times an A, 10 times a B, aso...), put the vectors in a database and use them as support vectors.
3.) You need a rating algorithm which rates the user drawing by comparing it to the support vectors (this might be the most interesting part of it). I could think of measuring the distances of the support vectors start and end- points to the drawn vectors. The svm with the lowest distance is the letter you take. Then you might introduce a distance which is the "border", and take all user drawings above this border as unrecognized.
A second approach might be that you generate images with the Letters (eg. white background and black letter (non- anti aliased)). You generate again an image of the user drawing and resize it to the image to compare with, trying to "overlap" it exactly. Then you count the black pixels that matches in the two images and take the letter with the most matchings.
But, since i implemented something similar, i can tell that the svm approach is more satisfying since you can add support vectors if the result is not good enough. The quintessence is for sure your rating algorithm.
Anyhow sounds like a couple of weeks of work.
EDIT: Since this an interesting field i did some research and found a thesis about handwriting recognition. Have a look on this: http://risujin.org/cellwriter/. It basically describes the svm approach i mentioned and gives some algorithms that might help you.
您始终可以使用手势识别 ...但这对于像这样的自定义场景来说非常困难。
否则,您可能会在 Quartz 至少会为您完成部分工作。我有兴趣看看你如何解决这个问题......这听起来像是一条相当困难/有趣的道路。
You could always use Gesture Recognition... but that's pretty difficult for a custom scenario like this.
Otherwise you may find something in Quartz that will do at least part of this for you. I'm interested in seeing how you solve this.. it sounds like a rather difficult/interesting road ahead.