Ask Your Question
0

How to prepare labeled data for action recognition video datasets using multiclass svm? [closed]

asked 2018-12-28 03:00:15 -0600

arti gravatar image

updated 2018-12-28 03:29:49 -0600

Hello all, i have read many examples of binary svm and got how to apply...but still suffering in multiclass svm . I'm not getting how to prepare multi-class action data for training along with labels. how to train svm for multiple classes and test. my data set have 10 classes like running, walking ,biking riding, waving, walking etc. and each class have 20 videos. so what should be label for each class. Please give me some reference regading multiclass. Thanks

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2018-12-29 03:02:46.918433

Comments

before you can classify anything, you have to extract features from the video data. so what are you planning to do there ?

have e.g. a look here

berak gravatar imageberak ( 2018-12-28 03:01:39 -0600 )edit
1

I have 4 features of each data like, lbp,hog,glcm and sift

arti gravatar imagearti ( 2018-12-28 03:06:41 -0600 )edit
1

i have extracted features from video data and then created dictionary using BOW in .yml files. now i want to use multi class svm for classification

arti gravatar imagearti ( 2018-12-28 03:17:10 -0600 )edit

can you give us information about the dimensions of the features ?

berak gravatar imageberak ( 2018-12-28 03:17:26 -0600 )edit

i have 20 dectionaries of each 10 class videos, sow to use svm to classifie them

arti gravatar imagearti ( 2018-12-28 03:18:33 -0600 )edit

yes features are in n*1 dimension .

arti gravatar imagearti ( 2018-12-28 03:21:01 -0600 )edit
berak gravatar imageberak ( 2018-12-28 07:03:39 -0600 )edit

answered here

berak gravatar imageberak ( 2018-12-29 03:03:11 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-28 07:01:26 -0600

berak gravatar image

updated 2018-12-28 07:04:43 -0600

opencv's SVM can handle multi-class problems, it will make an one-vs-all problem for each class from it internally .

i can't give you python code (c++ person here), but you have to flatten each of your features to a single row, and stack them vertically into a single numpy array, so it looks like this:

FEATURES                       LABELS

feature1                          5
feature2                          3
feature3                          1
...

the features need to be a float32 numpy array, and the labels an int32 1xN numpy array, then you can train your SVM:

svm = cv2.ml.SVM_create()
svm.train(features, cv2.ml.ROW_DATA, labels)

later you can predict on test features, reshaped and converted in the same way to a single row:

predicted = svm.predict(feature)
edit flag offensive delete link more

Comments

thanks a lot for the explanation.....means i have to train svm for each class of videos and at the time of test i have to test input with each train svms? ..what is the criteria for assigning labels...how to assign label for each class. In opencv document it is defied as fallows

 // Set up training data
    float labels[4] = {1.0, -1.0, -1.0, -1.0};
    Mat labelsMat(4, 1, CV_32FC1, labels);

    float trainingData[4][2] = { {501, 10}, {255, 10}, {501, 255}, {10, 501} };
    Mat trainingDataMat(4, 2, CV_32FC1, trainingData);

but i'm not getting in my case. i have 10 classes like running, walking , biking etc. and each class have 20 sample videos. then what should be label size and values in my case for each class.

arti gravatar imagearti ( 2018-12-28 10:26:02 -0600 )edit

means i have to train svm for each class

while you can do that, no, you probably should train 1 SVM with all the data you have.

.how to assign label for each class

simply like: 0:running, 1:standing, 2:whatever..

(this is also the number, the SVM will predict later.)

berak gravatar imageberak ( 2018-12-28 10:38:32 -0600 )edit

few more doubt please.... means in my case i have to take labels like

 float labels[10] = {0, 1, 2, 3,.......10};
 Mat labelsMat(10, 1, CV_32FC1, labels);

and training data for each class

float trainingData1[4] [n]= { feature1, feature2, feature3, feature4};
Mat trainingDataMat1(4, n, CV_32FC1, trainingData1);

then create svm for each class such as

Ptr<SVM> svm1 = SVM::create();

svm1->train(trainingDataMat1, ROW_SAMPLE, labelsMat);

here each svm should be trained with same labelsMat or i have to define different labels for each class?

and at the time testing i have to apply predict function with each svm1...svmN like

float response1 = svm1->predict(sampleMat); . . . . float responseK = svmN->predict(sampleMat);

then accuracy is calculated??

arti gravatar imagearti ( 2018-12-28 20:20:03 -0600 )edit

Question Tools

Stats

Asked: 2018-12-28 03:00:15 -0600

Seen: 250 times

Last updated: Dec 28 '18