|
|
|
@ -1,19 +1,21 @@
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
SVM and KNearest digit recognition.
|
|
|
|
|
SVM, Random forest and KNearest digit recognition.
|
|
|
|
|
Modified from the OpenCV example.
|
|
|
|
|
|
|
|
|
|
Sample loads a dataset of handwritten digits from '../data/digits.png'.
|
|
|
|
|
Then it trains a SVM and KNearest classifiers on it and evaluates
|
|
|
|
|
Then it trains a Random Forest, SVM and KNearest classifiers on it and evaluates
|
|
|
|
|
their accuracy.
|
|
|
|
|
|
|
|
|
|
Following preprocessing is applied to the dataset:
|
|
|
|
|
- Moment-based image deskew (see deskew())
|
|
|
|
|
- Digit images are split into 4 10x10 cells and 16-bin
|
|
|
|
|
histogram of oriented gradients is computed for each
|
|
|
|
|
cell
|
|
|
|
|
- Digit images are split into 4 10x10 cells and 16-bin histogram of oriented
|
|
|
|
|
gradients is computed for each cell
|
|
|
|
|
- Transform histograms to space with Hellinger metric (see [1] (RootSIFT))
|
|
|
|
|
|
|
|
|
|
Or in the "simple setting":
|
|
|
|
|
- Only moment-based image deskew (see deskew())
|
|
|
|
|
|
|
|
|
|
[1] R. Arandjelovic, A. Zisserman
|
|
|
|
|
"Three things everyone should know to improve object retrieval"
|
|
|
|
|