如何使用EigenObjectRecognizer训练图像

时间:2013-05-09 04:44:28

标签: c# emgucv

我正在使用emguCV开发一个C#应用程序,我是emguCV的新手。我在互联网上看过这个例子。

Image<Gray, Byte>[] trainingImages = new Image<Gray,Byte>[5];  
        trainingImages[0] = new Image<Gray, byte>("brad.jpg");
        trainingImages[1] = new Image<Gray, byte>("david.jpg");
        trainingImages[2] = new Image<Gray, byte>("foof.jpg");
        trainingImages[3] = new Image<Gray, byte>("irfan.jpg");
        trainingImages[4] = new Image<Gray, byte>("joel.jpg");
 String[] labels = new String[] { "Brad", "David", "Foof", "Irfan" , "Joel"}
  MCvTermCriteria termCrit = new MCvTermCriteria(16, 0.001); 

    EigenObjectRecognizer recognizer = new EigenObjectRecognizer(
       trainingImages,
       labels,
       5000,
       ref termCrit);
        Image<Gray,Byte> testImage = new Image<Gray,Byte>("brad_test.jpg");

     String label = recognizer.Recognize(testImage);
     Console.Write(label);

我需要知道的是如何训练所有图像?

1 个答案:

答案 0 :(得分:0)

recognizer.Recognize(testImage) RETURN EigenObjectRecognizer.RecognitionResult

所以你可以尝试:

EigenObjectRecognizer.RecognitionResult helo = recognizer.Recognize(result);

Console.Write(helo.lable);