Ask Your Question

Revision history [back]

I have C++ sample code from one moderator. The code only works in release mode. The data type of CV_32FC1 is not working for C++ either. Here include some code snippet:

Ptr<SVM> svm = SVM::create();
Mat tc;
trainingClasses.convertTo(tc, CV_32S);
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::POLY);//CvSVM::RBF, CvSVM::LINEAR ...
svm->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 1000, 1e-6));
svm->setDegree(0.5); // for poly
svm->setGamma(1); // for poly/rbf/sigmoid
svm->setCoef0(0); // for poly/sigmoid

svm->setC(7); // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR
svm->setNu(0.5); // for CV_SVM_NU_SVC, CV_SVM_ONE_CLASS, and CV_SVM_NU_SVR
svm->setP(0.0); // for CV_SVM_EPS_SVR

Ptr<cv::ml::TrainData> t = TrainData::create(trainingData, SampleTypes::ROW_SAMPLE, tc);
cout << "SVM training ..." << endl;
svm->trainAuto(t);

I would guess there is certain serious issue in the implementation regarding the selection of parameters.