简体   繁体   English

识别用户手指在iPhone屏幕上绘制的数字的最佳方法

[英]Best way to recognise number drawn by user's finger on iPhone screen

I'm planning on letting a user draw the shape of a number (1 to 9) in the shape of a 7-segment display. 我打算让用户以7段显示的形状绘制数字(1到9)的形状。 What is the best way to detect what number was drawn? 检测抽取的数字的最佳方法是什么?

I know how to do all the touch-tracking and UIGestureRecogniser stuff - I'm looking for a good logic of doing it. 我知道如何做所有触摸跟踪和UIGestureRecogniser的东西 - 我正在寻找一个良好的逻辑来做到这一点。

So far, I've got: When a touch moves from 1 half of a segment to the other, highlight that seg. 到目前为止,我已经得到:当一个触摸从一个段的一半移动到另一个段时,突出显示该段。 Once touches are finished, check what segs have been highlighted and decide what number drawn. 触摸完成后,检查突出显示的segs并确定绘制的数字。

Ways I've thought of improving it: Draw a shape of the finger's path on screen. 我想过改进它的方法:在屏幕上绘制手指路径的形状。 If the line intersects the middle of a seg, highlight that seg. 如果线与seg的中间相交,则突出显示该seg。

Anyone got any tips or better ways of doing this? 有人有任何提示或更好的方法吗? I'm open to any suggestion - even if it means scrapping all my code and starting from scratch. 我愿意接受任何建议 - 即使这意味着要废弃我的所有代码并从头开始。

I've used implementations of the $ stroke recognizers for drawn number recognition. 我已经使用$ stroke识别器的实现来绘制数字识别。

Both algorithms link to several Objective-C / iOS implementations. 两种算法都链接到几个Objective-C / iOS实现。

The recognizers will compare input against predefined patterns based on different algorithms (detailed explanation available on the linked pages). 识别器将基于不同的算法将输入与预定义模式进行比较(链接页面上的详细说明)。 For this to work you'll have to make your own number patterns (basically just draw something and let the recognizer convert this to a data structure you store for later use). 为此,你必须制作自己的数字模式(基本上只是绘制一些东西,让识别器将其转换为你存储的数据结构供以后使用)。 Then on user input compare to the patterns you recorded earlier to find a match. 然后在用户输入上比较您之前记录的模式以找到匹配项。

The $1 recognizer was sufficient for my application where I would let the user train first to practice drawing the numbers. 1美元的识别器足以满足我的应用需求,我会让用户首先练习绘制数字。 The $N recognizer is able to distinguish between more complex stokes and might accept more complex drawn numbers. $ N识别器能够区分更复杂的stokes并且可能接受更复杂的绘制数字。 This is something you will have to experiment with. 这是你必须要试验的东西。

If you're interested in detecting the numbers 1-9, check out BGNumericalGlyphRecognizer . 如果您对检测数字1-9感兴趣,请查看BGNumericalGlyphRecognizer I spent several months working with an $N-multistroke recognizer to create ScribbleMath (a math app that allows kids to draw their answers on the screen) and open-sourced the core logic. 我花了几个月的时间使用$ N-multistroke识别器来创建ScribbleMath(一个允许孩子们在屏幕上绘制答案的数学应用程序)并开源核心逻辑。 It turns out $N recognizers have a hard time differentiating 6 and 9, and are also bad at recognizing very simple letters like 1 and "-", and I created logic for handling those better. 事实证明$ N识别器很难区分6和9,并且也很难识别非常简单的字母,如1和“ - ”,并且我创建了处理这些更好的逻辑。 It's not perfect, but it'll get you farther than an $N recognizer out of the box. 它并不完美,但它会让你比开箱即用的N识别器更远。 Enjoy! 请享用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM