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);
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) ?
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.
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 ?
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.
"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
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.