Ask Your Question
0

Regarding multi class SVM and superpixels.

asked 2018-02-01 10:02:13 -0500

vps gravatar image

updated 2018-02-01 11:12:39 -0500

berak gravatar image

Hi All, I am working on human joint estimation. I am planning to use SVM classifier.

1) I want to find out the 15 human body parts or joints from the image. Does Opencv supports multi class SVM or I have to train one class with all other?

2) I am also planning to use super pixels instead of pixels. I have created SLIC super pixel algorithm. Each superpixel center has L, a ,b depth , x and y values. Anyone have idea about that, how to pass the superpixels to SVM classifier?

Thanks.

edit retag flag offensive close merge delete

Comments

1

1) " Does Opencv supports multi class SVM" -- yes.

2) L, a ,b depth , x and y -- so, that's not opencv's implementation, right ? (but what is it then ?)

how do you store that ?

what is the range of the individual features (you somehow need "normalized" data, not nessecarily in [0,1] range, but at least all your 5 feature elements should have the same range) ?

berak gravatar imageberak ( 2018-02-01 10:07:57 -0500 )edit

Thanks for your response. 1) Multi class SVM: So, I can pass 15 labels in one row of training matrix? It will be great, if you share the name of the related documents or research papers. 2) I am storing these data in the vector by using the structure. L, a. b and depth have range from 0 to 255.

vps gravatar imagevps ( 2018-02-01 10:16:46 -0500 )edit
1

any chance, you have a person detection in front of it, so you can make the x,y coords relative to the person's center ? (absolute coords are terrible here, to my knowledge. a person standing on the left side of the image, will yield entirely different results, than a person on the right side)

for any kind of machine learning, you would need "ground truth" (manually) labelled data. what about that ?

berak gravatar imageberak ( 2018-02-01 10:26:16 -0500 )edit
1

I already found the center point of the person. As per the opencv documentation, I have to train one class with all. So, I need 15 iterations for 15 classes.

vps gravatar imagevps ( 2018-02-01 10:27:44 -0500 )edit
1

"As per the opencv documentation, I have to train one class with all" -- not true. (where does it say so ?)

let's focus on the "labelled train data" problem. how are you going to do that ? you'll need at least a few hundred correctly labelled superpixels

berak gravatar imageberak ( 2018-02-01 10:39:10 -0500 )edit

I read this information from this link. It is written just above the four images. link text

I will make the tool for label the images. Every body parts will have different color. I have attached one sample image from the internet. link text Please check the b image.

Thank you.

vps gravatar imagevps ( 2018-02-01 10:46:13 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-02-01 11:00:18 -0500

berak gravatar image

updated 2018-02-01 11:37:00 -0500

so, let's try a first iteration of an "answer" here...

for any kind of opencv machine learning, we'll need a single Mat for the train data, where each feature is on a flat row

assuming, you got something like this:

struct superpixel {
      float L,a,b;
      float depth;
      float x,y;
};
vector<superpixel> sp;

we need to repack it into a single cv::Mat, with each superpixel on a row (also, process it a bit):

Mat spmat(const superpixel &s, const Size &size, const Point &person_center) {
        Mat_<float> row(1,5);
        row << s.L/255, sp.a/255, s.b/255, s.depth/255, 
              (s.x-person_center.x)/size.width, 
              (s.y-person_center.y)/size.height;
        return row;
}

Mat trainData, trainLabels;
for (size_t i=0; i<sp.size(); i++) {
        Mat row = spmat(sp[i], image.size(), person_center);
        trainData.push_back(row);
        int classId = ???? (an int in [0..15]) 
        // again, it needs manually labelled train data, see comments above !
        trainLabels.push_back(classId);
}

then we can setup the SVM, and train it:

Ptr<ml::SVM> svm = ml::SVM::create();
// optionally change params, like a LINEAR kernel
svm->train(trainData, 0, trainLabels);

then, later, you can classify your test superpixels:

Mat row = spmat(sp[i], image.size(), person_center);
int classId = (int)svm->predict(row);
edit flag offensive delete link more

Comments

@berak thanks for your suggestion. I will try this and will update here.

vps gravatar imagevps ( 2018-02-06 03:06:40 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-01 10:02:13 -0500

Seen: 194 times

Last updated: Feb 01 '18