Ask Your Question
1

Question regarding feeding extracted HoG features into CvSVM's train

asked 2012-08-06 23:33:20 -0600

sub_o gravatar image

updated 2012-08-07 00:49:22 -0600

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

I've managed to extract features and locations using:

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 given 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 ?

Could anyone please explain to me how am I supposed to tackle this ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-08-07 05:40:23 -0600

sub_o gravatar image

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 !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-08-06 23:33:20 -0600

Seen: 2,094 times

Last updated: Aug 07 '12