2017-08-08 19 views
0

SURFアルゴリズムでハッシングテクニックを使用できるかどうか聞いてみたいと思います。テスト画像と保存された画像データセットを照合して顔認識をするプログラムを作った。ハッシュ付きSURF

Accord.netを使用し、このライブラリのBOWによる機能のバッグを作成した後、ID3デシジョンツリーとKNNを作成しましたが、どちらの方法でも結果はあまり良くありませんでした。よりよい結果が得られるか、これは実行可能ではありませんか? これはBOW

    private void button2_Click(object sender, EventArgs e) 
    { 
     try 
     { 
      var watchFEC = System.Diagnostics.Stopwatch.StartNew(); 
      Accord.Math.Random.Generator.Seed = 0; 
      bow.ParallelOptions.MaxDegreeOfParallelism = 1; 
      bow.Learn(DatasetImages); 
      // After this point, we will be able to translate 
      // images into double[] feature vectors using 
      features = bow.Transform(DatasetImages); 
      watchFEC.Stop(); 
      var elapsedMs = watchFEC.ElapsedMilliseconds; 
      MessageBox.Show("Feature Extraction and Clastering is done" + '\n' + "Time for Feature Extraction and Clastering for Dataset is: " + elapsedMs.ToString() + " ms"); 
     } catch { MessageBox.Show("Error"); }  } 

ためのコードであると

private void button3_Click(object sender, EventArgs e) 
    { 
     try 
     { 
      var watchLearn = System.Diagnostics.Stopwatch.StartNew(); 
      inputs = features.ToInt32(); 
      tree = teacher.Learn(inputs, outputs); 
      error = new ZeroOneLoss(outputs).Loss(tree.Decide(inputs)); 
      MessageBox.Show("Error rate of learning is : "+error.ToString()); 
      watchLearn.Stop(); 
      var elapsedMs = watchLearn.ElapsedMilliseconds; 
      MessageBox.Show("Learning is done" + '\n' + "Time for Learning is: " + elapsedMs.ToString() + " ms"); 
     } 
     catch(Exception ex) { MessageBox.Show("Error"+ex); } 

    } 

とテスト

 private void button4_Click_1(object sender, EventArgs e) 
    { 
     try 
     { 
      var watchTest = System.Diagnostics.Stopwatch.StartNew(); 
      Bitmap[] testimage = new Bitmap[1]; 
      testimage[0] = (Bitmap)pictureBox1.Image; 
      var ff = bow.Transform(testimage); 
      ff.ToInt32(); 
      var predicted = tree.Decide(ff); 
      int i = 1; 
      for (i = 1; i < sizeofdataset; i++) 
      { 
       if (predicted[0] == Convert.ToInt16(workSheet.Cells[i, 3].Value.ToString())) 
       { 

        listBox1.SelectedItem = i; 
        MessageBox.Show("Test" + i); 
        break; 
       } 
      } 
      MessageBox.Show("Test" + predicted[0]); 
      pictureBox2.Image = new Bitmap(workSheet.Cells[i, 1].Value.ToString()); 
      watchTest.Stop(); 
      var elapsedMs = watchTest.ElapsedMilliseconds; 
      MessageBox.Show("Time for Testing is: " + elapsedMs.ToString() + " ms"); 
     } 

     catch (Exception ex) { MessageBox.Show("Error" + ex); } 

    } 
+0

こんにちはHiraqui、あなたは、あなたのプロジェクトの完全な.zipファイルを投稿してくださいすることができた場合Accord.NETの問題追跡ツールには、ここで問題となるものを簡単に検出できるようになる可能性があります。ただし、意思決定ツリーではなくSVMを使用してみましたか? ID3デシジョンツリーよりも高速で、信頼性が高いことがよくあります(少なくともAccord.NET Frameworkでは)。 – Cesar

+0

@Cesar、返事ありがとう、私はあなたの電子メールに私のフルプログラムを送って、私はSVMを試していない –

答えて

0

代わりのID3やK-NNのため、このコードを学ぶために、このコードで、試してみてくださいChi-SquareカーネルでSVMを使用しています。

SVMを試してみたい場合は、example on how to create multi-class kernel SVMs at the bottom of this page (see second example)があります。 Chi-Square SVMを作成するには、 "ChiSquare"で "Gaussian"と書かれた場所をすべて置き換えることができます。

プロジェクトの課題トラッカーに示されているように{「インデックスが配列の境界外にありました」}で実行された場合は、トレーニングやテストのサンプルがないクラスがあると思います。クラス番号が0から始まり、出力ベクトルの最高クラスのラベルがnumber_of_classes - 1に対応し、この間隔に関連するトレーニングサンプルなしで整数がないことを、すべてのクラスについて十分なトレーニングサンプルがあることを確認してください。

私はAccord.NET Frameworkのカイ二乗のカーネルを使用してのSVMを訓練する方法について例を下回る掲載しています

// Let's say we have the following data to be classified 
// into three possible classes. Those are the samples: 
// 
double[][] inputs = 
{ 
    //    input   output 
    new double[] { 0, 1, 1, 0 }, // 0 
    new double[] { 0, 1, 0, 0 }, // 0 
    new double[] { 0, 0, 1, 0 }, // 0 
    new double[] { 0, 1, 1, 0 }, // 0 
    new double[] { 0, 1, 0, 0 }, // 0 
    new double[] { 1, 0, 0, 0 }, // 1 
    new double[] { 1, 0, 0, 0 }, // 1 
    new double[] { 1, 0, 0, 1 }, // 1 
    new double[] { 0, 0, 0, 1 }, // 1 
    new double[] { 0, 0, 0, 1 }, // 1 
    new double[] { 1, 1, 1, 1 }, // 2 
    new double[] { 1, 0, 1, 1 }, // 2 
    new double[] { 1, 1, 0, 1 }, // 2 
    new double[] { 0, 1, 1, 1 }, // 2 
    new double[] { 1, 1, 1, 1 }, // 2 
}; 

int[] outputs = // those are the class labels 
{ 
    0, 0, 0, 0, 0, 
    1, 1, 1, 1, 1, 
    2, 2, 2, 2, 2, 
}; 

// Create the multi-class learning algorithm for the machine 
var teacher = new MulticlassSupportVectorLearning<ChiSquare>() 
{ 
    // Configure the learning algorithm to use SMO to train the 
    // underlying SVMs in each of the binary class subproblems. 
    Learner = (param) => new SequentialMinimalOptimization<ChiSquare>() 
    { 
     // Estimate a suitable guess for the Gaussian kernel's parameters. 
     // This estimate can serve as a starting point for a grid search. 
     UseKernelEstimation = true 
    } 
}; 

// Configure parallel execution options (or leave it at the default value for maximum speed) 
teacher.ParallelOptions.MaxDegreeOfParallelism = 1; 

// Learn a machine 
var machine = teacher.Learn(inputs, outputs); 

// Obtain class predictions for each sample 
int[] predicted = machine.Decide(inputs); 

// Get class scores for each sample 
double[] scores = machine.Score(inputs); 

// Compute classification error 
double error = new ZeroOneLoss(outputs).Loss(predicted); 
関連する問題