Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help on CvSVM

I couldnt find proper references about how to pass the SVM parameters to the opencv cvSvm class. I got the parameter list, but not any tutorial on how to convert the parameters to the CV data structures.

Can I have some help please?

like image 652
Sanjay Nambiar Avatar asked Mar 07 '11 09:03

Sanjay Nambiar


1 Answers

Construct a CvSVMParams object.

Its members are:

  • svm_type: SVM algorithm to use
  • kernel_type: SVM kernel form
  • degree: Degree for polynomial kernel
  • gamma: Scale for polynomial, RBF or sigmoid kernel
  • coef0: Offset for polynomial or sigmoid kernel
  • C: C ratio for selecting support vectors
  • nu: nu value for nu-SVR algorithm
  • p: p value for eps-SVR
  • class_weights: Class weights for C-SVM
  • term_crit: Termination criteria in CvTermCriteria

Change appropriate fields and pass it to CvSVM constructor. An SVM will be trained with your parameters.

CvSVMParams params ;
params.svm_type = CvSVM::C_SVC ;
params.kernel_type = CvSVM::RBF ;
params.gamma = 0.5 ;
CvSVM svm(&samples, &labels, 0, 0, params) ;

See documentation of CvSVM for more information: http://opencv.willowgarage.com/documentation/cpp/support_vector_machines.html

like image 129
Tugrul Ates Avatar answered Oct 22 '22 17:10

Tugrul Ates