Lahori
Lahori

Reputation: 1091

using svmlight model file in opencv

I have been working on training pedestrian detection classifier based on HOG features. Presently I have done the followings:

a) Extracted HOG features of all files i.e. Positive and Negative and saved those features with label i.e. +1 for positive and -1 for negative in file.

b)downloaded svmlight, extracted binaries i.e. svm_learn, svm_classify.

c) passed the "training file" (features file) to svm_learn binary which produced a model file for me.

d) passed "test file" to svm_classify binary and got result in predictions file.

Now my question is that "What to do next and how?". i think i know that now i need to use that "model file" and not "predictions file" in openCV for detection of pedestrian in video but somewhere i read that openCV uses only 1 support vector but i got 295 SV, so how do i convert it into one proper format and use it and any further compulsory steps if any.

I do appreciate your kindness!

Upvotes: 0

Views: 1115

Answers (1)

Bull
Bull

Reputation: 11941

It is not true that OpenCV (presumably you are talking about CvSVM) uses only one support vector. As pointed out by QED, what OpenCV does do is to optimize a linear SVM down to one support vector. I think the idea here is that the support vectors define the classification margin, but to do the actual classification only the separating hyperplane is needed and that can be defined with one vector.

Since you have a svmlight model file, and CvSVM can't read that, you have the following options:

  1. train a CvSVM and save the mode as a CvStatsModel file, that you can load tha tlater to get the support vecotrs.
  2. write some code to convert an svmlight model file into a CvStatsModel file (but for this you have to understand both formats).
  3. get source for svmlight, the bit that reaads the modelfile, and integrate it into your OpenCV application
  4. You may use LIBSVM instead, but really you are then faced with the same problems as svmlight.

For ideas on how to convert the support vectors so you can use them with the HOG detector see Training custom SVM to use with HOGDescriptor in OpenCV

Upvotes: 2

Related Questions