Ask Your Question
1

How to configure CvSVM for image classification

asked 2013-05-25 12:29:10 -0600

Heshan Sandeepa gravatar image

updated 2013-05-25 17:27:26 -0600

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;
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-05-28 06:18:44 -0600

Heshan Sandeepa gravatar image

hi everyone, anyway i use to this way to configure the SVM. If anyone has better idea, any comment, any suggestion or whatever thing about following code, plz comment it here. i use only 30 samples for one character and 16 features for one sample, i know thats not enough at all. but to get the clear idea about SVM, i use this way.

    float labels[1080][1] = {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
                         2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,  2.0,
                         3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,  3.0,
                         4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,  4.0,
                         5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,
                         6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,  6.0,
                         7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,
                         8.0,  8.0,  8.0,  8.0,  8.0,  8.0 ...
(more)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-05-25 12:29:10 -0600

Seen: 519 times

Last updated: May 28 '13