1
votes

This is a silly question since I'm quite new to SVM,

I've managed to extract features and locations using OpenCV's HoGDescriptor:

vector< float > features;
vector< Point > locations;
hog_descriptors.compute( image, features, Size(0, 0), Size(0, 0), locations );

Then I proceed to use CvSVM to train the SVM based on the features I've extracted.

Mat training_data( features );
CvSVM svm;
svm.train( training_data, labels, Mat(), Mat(), params );

Which gave me an error:

OpenCV Error: Bad argument (There is only a single class) in cvPreprocessCategoricalResponses, file /opt/local/var/macports/build/ 

My question is that, how do I convert the vector < features > into appropriate matrix to be fed into CvSVM ? Obviously I am doing something wrong, the OpenCV's tutorial shows that a 2D matrix containing the training data is fed into SVM. So, how do I convert vector < features > into a 2D matrix, what are the values in the 2nd dimension ?

What are these features exactly ? Are they the 9 bins consisting of normalized magnitude histograms ?

1

1 Answers

2
votes

I found out the issue, since I was testing whether it is correct to pass feature vectors into the SVM in order to train it, I didn't bother to prepare both negative and positive samples.

Yet, CvSVM requires at least 2 different classes for training, that's why the error it threw.

Thanks a lot anyway !