Handwriting Number Classification
An computer vision project, based on cimg library and svm training, to classify handwriting number.
1. Project Requirement
- A photo in which an A4 paper is placed on the desk, with some handwriting numbers on
1.2 Output
- A string of the numbers written on the paper, like “70026548853”
- Modify the paper in the photo into a standard A4 paper
- Implement the segmentation of the numbers, dividing them into single number
- Use Adaboost or SVM to train a classifier of the handwriting numbers
- Classify the handwriting numbers with the trained classifier
2. Coding Environment & 3rd Party Library
3. Implementation Procedure
-
Find the 4 vertices of the paper
-
Modify the paper into a standard A4 paper
-
Segmentation of the numbers in order:
- Convert into binary image
- Use vertical histogram to divide the source image into sub-image (each sub-image contains a line of numbers)
- Use horizontal histogram to divide the line-sub-image into several row-sub-images
- Foreach sub-image, implement dilation to thicken the number (and join the broken ones)
- Foreach sub-image, use connected-component_labeling algorithm to divide the single number:
https://en.wikipedia.org/wiki/Connected-component_labeling
- Foreach sub-image, save all single number images and a list of their name in .txt
-
Use libsvm to train model and test, and predict the number finally
- Data prepairing:
- Model training:
- extract the HOG features of each image and construct them into svm format (in **.txt)
- Scale the features(in **.txt) with
svm-scale.exe (search the windows/ folder)
- Train the model with
svm-train.exe, and get **.model
- (Optional) Test the data with
svm-predict.exe and see the accuracy (modify the training parameter to get the highest accuracy)
- Number predicting:
- read the number images you segmented just now and do prediction with the trained model
4. Result Screenshots
- 4 vertices of the paper & A4 paper modification

5. Some key points
5.1 Broken numbers joining
6. Code and Algorithm Explanation
-
Segmentation of the numbers & Broken numbers joining :
http://blog.csdn.net/qq_33000225/article/details/73123880 (Chinese version)
-
Prediction: (Waiting…)
7. Problems left
- Some numbers are connected to each other and are segmented together into one image…
- From the predict result above, we see that most of the 7s and 9s are classified into 1…
评论