问题描述
我正在开发一个使用OpenCV LibSVM的手写字符识别系统。我已经为特征向量提取了14个特征,包括Hu矩,仿射不变矩,角数等。对于每个角色,我使用5个样本(对于字母A,有5种类型的A')。我知道5个样本是不够的,但是在那时我每个角色只有5个样本。
我在opencv文档中使用了基本的LINEAR SVM示例。我的问题是,为了我的目的,我可以使用该文档示例吗?我读过有关使用多类SVM的OCR系统。我是否需要这种多类SVM用于我的应用程序。我不明白这一点。请有人解释一下吗?这是我的代码。
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;
推荐答案
这篇关于如何在OpenCV和C ++中配置CvSVM进行图像分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!