|
|
@ -1,19 +1,21 @@
|
|
|
|
#!/usr/bin/env python
|
|
|
|
#!/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'.
|
|
|
|
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.
|
|
|
|
their accuracy.
|
|
|
|
|
|
|
|
|
|
|
|
Following preprocessing is applied to the dataset:
|
|
|
|
Following preprocessing is applied to the dataset:
|
|
|
|
- Moment-based image deskew (see deskew())
|
|
|
|
- Moment-based image deskew (see deskew())
|
|
|
|
- Digit images are split into 4 10x10 cells and 16-bin
|
|
|
|
- Digit images are split into 4 10x10 cells and 16-bin histogram of oriented
|
|
|
|
histogram of oriented gradients is computed for each
|
|
|
|
gradients is computed for each cell
|
|
|
|
cell
|
|
|
|
|
|
|
|
- Transform histograms to space with Hellinger metric (see [1] (RootSIFT))
|
|
|
|
- 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
|
|
|
|
[1] R. Arandjelovic, A. Zisserman
|
|
|
|
"Three things everyone should know to improve object retrieval"
|
|
|
|
"Three things everyone should know to improve object retrieval"
|
|
|
|