std::vector<std::vector<double>> features;//storing features for all images
std::vector<double> feat;//for a single image
extract_highdim_face_lbp_descriptors(img, shape, feat); //dlib's function, storing extracted info in 'feat'
features.push_back(feat);
//Now all the info for all the images is stored in 'features' vector. I now need to train the data and make a suitable model using libsvm, precisely RBF kernel.
. LibSVM은 공백 기반 텍스트 형식을 사용합니다. 여기 (안된)
convert from CSV
쓰기가 이렇게 될 수있는이 형식 쓸 수있는 코드입니다 : - 당신이 LibSVM 필요하지 않습니다 -
ofstream f("data_file");
for (auto img : images) //each image should be
{
std::vector<double> feat;
shape = predictor(img);
extract_highdim_face_lbp_descriptors(img, shape, feat);
double label = is_neutral ? -1.0 : +1.0;
f << label;
for (int i = 0; i < feat.size(); ++i)
if (feat[i] != 0.0)
f<< " " << i << ":" << feat[i];
f << endl;
}
그리고 당신은 Dlib를 사용하는 경우 당신이 Dlib와 교육 과정을 만들 수 있습니다, here is an example of SVM training with dlib