i am trying to make a game in which i am tying to implement handwriting recognition,
what i exactly want is that when the user slides his finger on the screen a line should be created wherever he slides the finge开发者_如何转开发r and when he lifts his finger i want to check that the image which he created matches to any alphabet(a,b,c...z)and if yes then to which alphabet.
i tried drawing the lines using CGSprites but it is leading to a huge fps drop and later crashing of the app if the user keeps sliding his finger,but i have no idea how to recognize it.
can anyone please till me if this is anyway possible,if yes can you please provide me with some idea of how to approach this.
Thanks in Advance
For the line drawing I would suggest using basic OpenGL calls to draw the line. Store the points however you want with every touch moved event and then in the draw function for your node you should setup OpenGL state to meet your line drawing needs...
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.5f);
then iterate over your list of points and use something like
ccDrawLine(pA, pB);
to draw the line between those points.
As for using that data to detect letters, that's a very tricky problem. You might want to look for libraries to do that for you. If you're dead set on doing it yourself, then you should start with looking for research papers on handwriting recognition.
For drawing the line you can also use CCRibbon define a CCRibbon and keep a reference to it you should use a proper image for ribbon
CCRibbon *line = [CCRibbon ribbonWithWidth: image: length: color: fade:];
then in your touch handler when touch moves add new points to CCRibbon
[line addPointAt: width:];
I can think of three different solutions.
- Use an existing library. Maybe you will not find one written in Objective-C, but using any C or C++-Library should also be easy. For example you could use AMELiA or Lipi Toolkit.
- Write a Custom Gesture Recognizer for the different letters
- Implement it yourself. You could use neural networks or support vector machines. You can train them with some of the free datasets on the net. Markov Models are also commonly used to solve this problem. However unless you want to learn a lot of theory and have a good knowledge of mathematics I would not recommend this approach.
精彩评论