Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to configure Support vector machine for Optical Character Recognition

hi, i am developing a handwritten character recognition system using OpenCV LibSVM. i have extracted 14 features for the feature vector including Hu moments, affine invariant moments, numbers of corners etc. For each character, i use 5 samples( for letter "A", there 5 types of A's). I know 5 samples is not enough, but at the moments i have only 5 samples for each character.

I use the basic LINEAR SVM example in opencv documentation. My problem is, can i use that documentation example as it is, for my purpose. I have read about OCR systems that use multi- class SVMs. Do i need such Multi-Class SVM for my application. I do not understand about this. Please can someone explain ? Here is my code.

float labels[180][1] = {1.0, 2.0, 3.0, 4.0, 5.0, ,,,,, -> 180.0};
Mat matlabesls(180,1, CV_32FC1, labels);


Mat mattrainingDataMat(180, 14, CV_32FC1, ifarr_readtrainingdata);

CvSVMParams params;
params.svm_type    = CvSVM::C_SVC;
params.kernel_type = CvSVM::LINEAR;
params.term_crit   = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

CvSVM SVM;
SVM.train(mattrainingDataMat,matlabesls,Mat(),Mat(),params);

Mat matinput(1,14,CV_32FC1,ifarr_testarray);
is_recognizedcharacter= SVM.predict(matinput);

return is_recognizedcharacter;

How to configure Support vector machine for Optical Character RecognitionCvSVM for image classification

hi, i am developing a handwritten character recognition system using OpenCV LibSVM. i have extracted 14 features for the feature vector including Hu moments, affine invariant moments, numbers of corners etc. For each character, i use 5 samples( for letter "A", there 5 types of A's). I know 5 samples is not enough, but at the moments i have only 5 samples for each character.

I use the basic LINEAR SVM example in opencv documentation. My problem is, can i use that documentation example as it is, for my purpose. I have read about OCR systems that use multi- class SVMs. Do i need such Multi-Class SVM for my application. I do not understand about this. Please can someone explain ? Here is my code.

float labels[180][1] = {1.0, 2.0, 3.0, 4.0, 5.0, ,,,,, -> 180.0};
Mat matlabesls(180,1, CV_32FC1, labels);


Mat mattrainingDataMat(180, 14, CV_32FC1, ifarr_readtrainingdata);

CvSVMParams params;
params.svm_type    = CvSVM::C_SVC;
params.kernel_type = CvSVM::LINEAR;
params.term_crit   = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

CvSVM SVM;
SVM.train(mattrainingDataMat,matlabesls,Mat(),Mat(),params);

Mat matinput(1,14,CV_32FC1,ifarr_testarray);
is_recognizedcharacter= SVM.predict(matinput);

return is_recognizedcharacter;