2016-07-04 4 views
1

dlibを使用して表情を取得し、記述子を抽出し、libsvmを使用して得られたデータを訓練する表情認識プロジェクトを行っています。私はVisual Studio Community 2015でC++を使用しています。これまでは、高次元のLBP記述子を抽出し、libsvmを使用して得られた機能を理解し、訓練したいと考えています。私は私の 'フィーチャー'ベクトルの中のデータを理解できず、さらにそれをlibsvmの受け入れられたフォーマットのトレーニングに変換することができないので、ここで立ち往生しています。dlibを使用して高次元lbp記述子を抽出した後、LIBSVMでトレーニング

以下はコードスニペットです。この前に、ほとんどすべてが自明であると思います。

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.

答えて

1

あなたはラベルが学習プロセスを作るためとして、特徴量として格納する必要があります。 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

関連する問題