What are some algorithms for symbol-by-symbol handwriting recognition?

前端 未结 3 815
陌清茗
陌清茗 2021-01-02 19:16

I think there are some algorithms that evaluate difference between drawn symbol and expected one, or something like that. Any help will be appreciated :))

相关标签:
3条回答
  • 2021-01-02 19:31

    You can implement a simple Neural Network to recognize handwritten digits. The simplest type to implement is a feed-forward network trained via backpropagation (it can be trained stochastically or in batch-mode). There are a few improvements that you can make to the backpropagation algorithm that will help your neural network learn faster (momentum, Silva and Almeida's algorithm, simulated annealing).

    As far as looking at the difference between a real symbol and an expected image, one algorithm that I've seen used is the k-nearest-neighbor algorithm. Here is a paper that describes using the k-nearest-neighbor algorithm for character recognition (edit: I had the wrong link earlier. The link I've provided requires you to pay for the paper; I'm trying to find a free version of the paper).

    If you were using a neural network to recognize your characters, the steps involved would be:

    1. Design your neural network with an appropriate training algorithm. I suggest starting with the simplest (stochastic backpropagation) and then improving the algorithm as desired, while you train your network.
    2. Get a good sample of training data. For my neural network, which recognizes handwritten digits, I used the MNIST database.
    3. Convert the training data into an input vector for your neural network. For the MNIST data, you will need to binarize the images. I used a threshold value of 128. I started with Otsu's method, but that didn't give me the results I wanted.
    4. Create your network. Since the images from MNIST come in an array of 28x28, you have an input vector with 784 components and 1 bias (so 785 inputs), to your neural network. I used one hidden layer with the number of nodes set as per the guidelines outlined here (along with a bias). Your output vector will have 10 components (one for each digit).
    5. Randomly present training data (so randomly ordered digits, with random input image for each digit) to your network and train it until it reaches a desired error-level.
    6. Run test data (MNIST data comes with this as well) against your neural network to verify that it recognizes digits correctly.

    You can check out an example here (shameless plug) that tries to recognize handwritten digits. I trained the network using data from MNIST.

    Expect to spend some time getting yourself up to speed on neural network concepts, if you decide to go this route. It took me at least 3-4 days of reading and writing code before I actually understood the concept. A good resource is heatonresearch.com. I recommend starting with trying to implement neural networks to simulate the AND, OR, and XOR boolean operations (using a threshold activation function). This should give you an idea of the basic concepts. When it actually comes down to training your network, you can try to train a neural network that recognizes the XOR boolean operator; it's a good place to start for an introduction to learning algorithms.

    When it comes to building the neural network, you can use existing frameworks like Encog, but I found it to be far more satisfactory to build the network myself (you learn more that way I think). If you want to look at some source, you can check out a project that I have on github (shameless plug) that has some basic classes in Java that help you build and train simple neural-networks.

    Good luck!

    EDIT

    I've found a few sources that use k-nearest-neighbors for digit and/or character recognition:

    • Bangla Basic Character Recognition Using Digital Curvelet Transform (The curvelet coefficients of an original image as well as its morphologically altered versions are used to train separate k– nearest neighbor classifiers. The output values of these classifiers are fused using a simple majority voting scheme to arrive at a final decision.)
    • The Homepage of Nearest Neighbors and Similarity Search
    • Fast and Accurate Handwritten Character Recognition using Approximate Nearest Neighbors Search on Large Databases
    • Nearest Neighbor Retrieval and Classification

    For resources on Neural Networks, I found the following links to be useful:

    • CS-449: Neural Networks
    • Artificial Neural Networks: A neural network tutorial
    • An introduction to neural networks
    • Neural Networks with Java
    • Introduction to backpropagation Neural Networks
    • Momentum and Learning Rate Adaptation (this page goes over a few enhancements to the standard backpropagation algorithm that can result in faster learning)
    0 讨论(0)
  • 2021-01-02 19:41

    Addendum

    If you have not implemented machine learning algorithms before you should really check out: www.ml-class.org

    It's a free class taught by Andrew Ng, Director of the Stanford Machine Learning Centre. The course is an entirely online-taught course specifically on implementing a wide range of machine learning algorithms. It does not go too much into the theoretical intricacies of the algorithms but rather teaches you how to choose, implement, use the algorithms and how diagnose their performance. - It is unique in that your implementation of the algorithms is checked automatically! It's great for getting started in machine learning at you have instantaneous feedback.

    The class also includes at least two exercises on recognising handwritten digits. (Programming Exercise 3: with multinomial classification and Programming Exercise 4: with feed-forward neural networks)

    The class has started a while ago but it should still be possible to sign up. If not, a new run should start early next year. If you want to be able to check your implementations you need to sign up for the "Advanced Track".

    One way to implement handwriting recognition

    The answer to this question depends on a number of factors, including what kind of resource constraints you have (embedded platform) and whether you have a good library of correctly labelled symbols: i.e. different examples of a handwritten letter for which you know what letter they represent.

    If you have a decent sized library, implementation of a quick and dirty standard machine learning algorithm is probably the way to go. You can use multinomial classifiers, neural networks or support vector machines.

    I believe a support vector machine would be fastest to implement as there are excellent libraries out there who handle the machine learning portion of the code for you, e.g. libSVM. If you are familiar with using machine learning algorihms, this should take you less than 30 minutes to implement.

    The basic procedure you would probably want to implement is as follows:

    Learning what symbols "look like"

    1. Binarise the images in your library.
    2. Unroll the images into vectors / 1-D arrays.
    3. Pass the "vector representation" of the images in your library and their labels to libSVM to get it to learn how the pixel coverage relates to the represented symbol for the images in the library.
    4. The algorithm gives you back a set of model parameters which describe the recognition algorithm that was learned.

    You should repeat 1-4 for each character you want to recognise to get an appropriate set of model parameters.

    Note: steps 1-4 you only have to carry out once for your library (but once for each symbol you want to recognise). You can do this on your developer machine and only include the parameters in the code you ship / distribute.

    If you want to recognise a symbol:

    Each set of model parameters describes an algorithm which tests whether a character represents one specific character - or not. You "recognise" a character by testing all the models with the current symbol and then selecting the model that best fits the symbol you are testing.

    This testing is done by again passing the model parameters and the symbol to test in unrolled form to the SVM library which will return the goodness-of-fit for the tested model.

    0 讨论(0)
  • 2021-01-02 19:42

    Have you checked Detexify. I think it does pretty much what you want http://detexify.kirelabs.org/classify.html

    It is open source, so you could take a look at how it is implemented. You can get the code from here (if I do not recall wrongly, it is in Haskell) https://github.com/kirel/detexify-hs-backend

    In particular what you are looking for should be in Sim.hs

    I hope it helps

    0 讨论(0)
提交回复
热议问题