I have used HOGDescriptors to compute the feature vector of an image, now I have to use SVM to create training set for a class. I have to create multiclass SVM as i have 6 classes each with 10 images. I do not know how to convert vector into Mat and how to label the class to create an xml file?
hog.compute(drawing, ders, Size(1, 1), Size(0, 0));
Mat Hogfeat; Hogfeat.create(ders.size(), 1, CV_32FC1);
for (int i = 0; i<ders.size(); i++)="" {="" hogfeat.at<float="">(i, 0) = ders.at(i);
}
int labels = {1}; Mat labelsMat(1, 1, CV_32SC1, labels);
Ptr<ml::svm> svm = ml::SVM::create(); svm->setType(ml::SVM::C_SVC); svm->setKernel(ml::SVM::LINEAR); svm->setGamma(3); svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 100, 1e-6));
Ptr<ml::traindata> tData = ml::TrainData::create(Hogfeat, ml::SampleTypes::ROW_SAMPLE, labelsMat); svm->train(tData);
svm->save("testing.xml");