Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

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.

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.

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.

like image 512
Craig Avatar asked Nov 17 '11 11:11

Craig


People also ask

What is the pull down screen on iPhone?

Control Center gives you instant access to the things you do the most. You can use Control Center to quickly take a picture, turn on Wi-Fi, control your Apple TV, and more.

What does swiping down on iPhone do?

To lower the top half of the screen, do one the following: On an iPhone with Face ID: Swipe down on the bottom edge of the screen. On an iPhone with a Home button: Lightly double-tap the Home button.


2 Answers

I've used implementations of the $ stroke recognizers for drawn number recognition.

  • $1 Unistroke recognizer
  • $N Multistroke recognizer

Both algorithms link to several Objective-C / iOS implementations.

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. The $N recognizer is able to distinguish between more complex stokes and might accept more complex drawn numbers. This is something you will have to experiment with.

like image 83
Joris Kluivers Avatar answered Sep 22 '22 14:09

Joris Kluivers


If you're interested in detecting the numbers 1-9, check out 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. 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. It's not perfect, but it'll get you farther than an $N recognizer out of the box. Enjoy!

like image 26
Ben Gotow Avatar answered Sep 20 '22 14:09

Ben Gotow