Ask Your Question
0

how to provide training data for svm classifier?

asked 2014-01-24 23:33:25 -0600

Parthi gravatar image

updated 2014-01-25 06:03:06 -0600

berak gravatar image

I am opencv newbie , i am trying build a Sign language recognition system the training data for the svm has to be set of 2D points.

if I have converted a set of Hand-gestures to contours, and i want to use that as a training data for SVM ?

what is process of converting those contours into training data?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-01-25 03:17:20 -0600

berak gravatar image

let's assume you want HuMoments for features,

for each contour, call moments(contour) , and get the HuMoments from that .

voila, now you got a 7 element feature vector per contour ( remember the demo above ? they had 2element features(points), you got 7element 'points' here.

probably the most easy way, to build the traindata and the trainlabels mats is to start with empty Mat's for both, and just push_back() the 7 humoments, one after the other into the traindatamat, and to push_back() 1 label into the trainlabels.

after you collected all your data, you just call traindata=traindata.reshape(1,num_train_items) to make a 2d Mat of it. in the end , it should look like this:

traindata                                  trainlabels

h0 h1 h2 h3 h4 h5 h6                       4
h0 h1 h2 h3 h4 h5 h6                       1
h0 h1 h2 h3 h4 h5 h6                       9
h0 h1 h2 h3 h4 h5 h6                       13
... 
(num_train_items rows of 7 elm)            (num_train_items rows of 1 elm)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-24 23:33:25 -0600

Seen: 496 times

Last updated: Jan 25 '14