Skip to content

Merakist/SVM-Digit-Recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVM-based Digit Recognition

A SVM-based OpenCV Project for recognizing handwritten digits in C++.

This project uses the MNIST Database of Handwritten Digits.

Installation

  1. Visit the official OpenCV website and install OpenCV.

  2. Clone this Repository (SVM-Recognition).

  3. Download MNIST Data and put the data files under SVM-Recognition/data.

t10k-images.idx3-ubyte
t10k-labels.idx1-ubyte
train-images.idx3-ubyte
train-labels.idx1-ubyte
  1. Input the following command in your command prompt to run.

NOTE: You need to run every command of this recipe in the SVM-Recognition root path:

cd build
cmake ..

Usage

1. Train

To train a SVM model, run the following command.

NOTE: You need to run every command of this recipe in the SVM-Recognition root path:

cd build
make train
cd train
./train

The program will train a SVM model by the training data train-images.idx3-ubyte and train-labels.idx1-ubyte, and will calculate the accuracy by t10k-images.idx3-ubyte and t10k-labels.idx1-ubyte.

2. Recognition

To run predictions of an image of a digit, make sure the image conforms to the format in MNIST database, i.e., a 28*28 bmp image. The filename of the image does not matter. So long as the image is in the right format and is a .bmp file, the program will run a prediction.

To start, put the image under SVM-Recognition/data. The program will only run predictions for the first occurrence of a .bmp file, so don't put more than one image.

NOTE: You need to run every command of this recipe in the SVM-Recognition root path:

cd build
make recognition
cd recognition
./recognition

The program will then print the prediction of the image.

Pre-trained Model

A pre-trained model is included: /SVM-Recognition/build/mnist_svm.xml with accuracy 97.54%.

Related Reading in Digit Recognition

About

A SVM-based Digit Recognition OpenCV project in C++.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published