6

I am trying to do some facial recognition using EmguCV. I was wondering if I can use EigenObjectRecognizer for this task? Can someone can explain me how to use it? Because if there is a no no-match photo, it also returns a value. Here is an example:

    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);

It returns "brad" .But if I change photo in testimage it also returns some name or even Brad.Is it good for face recognition to use this method? Or is there any better method?

Jean-François Côté
  • 4,200
  • 11
  • 52
  • 88
Ercan
  • 2,699
  • 10
  • 53
  • 60
  • 1
    Don't you have to train all of the other images as well? It looks like you only trained it to look for brad. – Robert Harvey May 14 '10 at 21:13
  • He seems to be passing an array of images and an array of labels to his recognizer. Why do you think he's not training them all? – Blindy May 14 '10 at 21:35
  • I trained it to look for brad because I want to taste image with Data base.Like I have 1 photo of person and I want to find who is it? – Ercan May 14 '10 at 21:51
  • That function: `"Create an object recognizer using the specific tranning[sic] data and parameters, it will always return the most similar object "` - so, Some further discriminating factor like "confidence" or in this domain "max acceptable distance", like EigenDistanceThreshold `Get or set the eigen distance threshold. The smaller the number, the more likely an examined image will be treated as unrecognized object. Set to a huge number (e.g. 5000) the recognizer will always treated the examined image as one of the known object` as noted by Ercan below – twobob May 10 '17 at 00:44

4 Answers4

1

I made some practice and found that when it does not found it returns empty string. Changing value 5000 to 1000 it gives more close value but ıf you are usıng web cam your photo for testing and in database must be almost same .

Ercan
  • 2,699
  • 10
  • 53
  • 60
  • I also have practiced it, seems if I have one test face then it labels all the faces as the label I kept for the test face. I want to recognize different faces as they have been labeled. It did not work out as yet. – Rick2047 Jul 15 '10 at 19:26
0
recognizer.Recognize(testImage) RETURN EigenObjectRecognizer.RecognitionResult

so you can try:

EigenObjectRecognizer.RecognitionResult helo = recognizer.Recognize(result);
Console.Write(helo.lable);
Alex
  • 4,821
  • 16
  • 65
  • 106
0

Well, I don't know Emgu Cv, but I think what Robert Harvey says is right. You have to train your neural network. Also, neural networks will always return a result, no matter what. If the result is wrong, it means you haven't trained your network enough.

Run CMD
  • 2,937
  • 3
  • 36
  • 61
  • But also i need wrong result to see there is no match. And report that not found.But if it returns some thing how can I make it? – Ercan May 14 '10 at 22:03
  • I'm surely not an expert in these things, but I think you're confusing standard yes/no , 1/0, "found/not found" programming with neural network programming (like face recognition is). A "Not found" issue cannot happen in a neural network ... Maybe you have to add a "Unknown" image, and train your network to recognize this as default ?? I don't know ... http://www.google.be/search?source=ig&hl=nl&rlz=&q=neural+networks&btnG=Google+zoeken&meta= http://www.google.be/search?source=ig&hl=nl&rlz=&q=fuzzy+logic&btnG=Google+zoeken&meta= – Run CMD May 17 '10 at 14:03
0

You could overload the Recognize function of Emgu.CV.EigenObjectRecognizer like:

public String Recognize(Image<Gray, Byte> image, out float distance)
      {
          int index;
          float eigenDistance;
          String label;
          FindMostSimilarObject(image, out index, out eigenDistance, out label);
          distance = eigenDistance;
          return (_eigenDistanceThreshold <= 0 || eigenDistance < _eigenDistanceThreshold) ? _labels[index] : String.Empty;
      }

Idea constructed on Overload Snippet from Codeproject

and in this way receive a running last derived distance like

float last_distance =0;
label = recognizer.Recognize(testImage, out last_distance);

This would give you a better idea of the value to put in

MCvTermCriteria termCrit = new MCvTermCriteria(trainingImages.count, 0.001);

EigenObjectRecognizer recognizer = new EigenObjectRecognizer(
                       trainingImages.ToArray(),
                       labels.ToArray(),
                       <<good max val derived from last_distance>>,
                       ref termCrit);

via simply piping it to a label and having a look at the range of values.

3 or 4 thousand maybe...

twobob
  • 354
  • 8
  • 22