Ask Your Question
1

OpenCV 2.4.2 FaceRec_demo.cpp - Interpreting output of Predict function

asked 2012-09-07 04:09:53 -0600

seetaram.nt gravatar image

updated 2012-09-07 10:06:53 -0600

AlexanderShishkov gravatar image

Hi All, I'm running the OpenCv2.4.2 Sample code Facerec_demo.cpp (Using Eigen Faces) on Fedora Linux (Code is here http://docs.opencv.org/trunk/modules/contrib/doc/facerec/facerec_tutorial.html).

I'm not able to interpret the PredictedLevel and Confidence values of the Predict functions. I also checked the output for various conditions of having matching and nonmatching input image. I have also gone through the OpenCV 2.4.2 documenation but not very clear about the interpretation of output of predict function?. The Test results of predict function is as follows.

  1. For matching Input face -> predictedLabel = 0; Confidence =0
  2. For Non matching Input Face -> predictedLabel = 1; Confidence =-1602920021
  3. For Slightly matching- means i have only 1 image in face database matching this image. then: predictedLabel = 1; Confidence =1594149678.

Request you to help me understand these values. I read in the documentation that, the predictedLabel should be -1 for nonmatching images but i'm getting 1?

Please let me know what Predictedlabel and Confidence values i should get for matching, non matching and slightly matching images? Please suggest

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-09-07 10:24:30 -0600

updated 2012-09-08 10:29:20 -0600

Please decide to either file a bug if you think there's one, post on the OpenCV QA page or on stackoverflow.com. I found at least these three versions:

So which one should I answer?

First of all how to interpret the labels. As outlined in the tutorials, each of the labels is assigned to a person, just take a look at the CSV file you feed into the demo. For example the images for s1 (subject 1) in the AT&T Database are assigned to 0:

/path/to/at/s1/2.pgm;0
/path/to/at/s1/7.pgm;0
/path/to/at/s1/6.pgm;0
...

While the images for s2 (subject 2) are assigned to 1:

/path/to/at/s2/2.pgm;1
/path/to/at/s2/7.pgm;1
/path/to/at/s2/6.pgm;1
...

So each label corresponds to the images of a person. I hope that makes sense.

Now let's get to your predicted confidence values. Actually the values you report on the Stackoverflow post make no sense to me. I have no idea how you can have negative values for the best matching face, because in the code I determine the Euclidean Distance, which should always be positive:

double dist = norm(_projections[sampleIdx], q, NORM_L2);

I just updated to the latest OpenCV revision in git and ran the Eigenfaces sample provided in the tutorial. To get the prediction and associated confidence I commented out the first prediction and wrote the following code. I am on a 32-bit Ubuntu 10.04:

// To get the confidence of a prediction call the model with:
//
int predictedLabel = -1;
double confidence = 0.0;

model->predict(testSample, predictedLabel, confidence);
//
// Output the prediction:
string result_message = format("Predicted class = %d / Actual class = %d / Confidence = %f", predictedLabel, testLabel, confidence);
cout << result_message << endl;

Running the demo on the CSV file given in the tutorial I get the follwoing output:

philipp@mango:~/git/facerecsamples_build$ ./facerec_eigenfaces /home/philipp/facerec/data/at.txt 
Predicted class = 37 / Actual class = 37 / Confidence = 1806.542475
Eigenvalue #0 = 2817234.89109
Eigenvalue #1 = 2065223.71308
Eigenvalue #2 = 1096613.63515
Eigenvalue #3 = 888103.94982
Eigenvalue #4 = 818941.86977
Eigenvalue #5 = 538914.47401
Eigenvalue #6 = 392433.54243
Eigenvalue #7 = 373805.54654
Eigenvalue #8 = 313921.17233
Eigenvalue #9 = 288902.01563

So the distance is 1806.542475 for me, a value which I would expect.

Determining the optimal threshold values is not a trivial task, so I can't give trivial answers on this. The threshold depends on your input data and as far as I know, there's no rule to calculate it. I would find the threshold by simply cross validating it on my input data.

If the problem persists, please file a bug report and give me as much details as necessary to reproduce the problem.

edit flag offensive delete link more

Comments

Hi, Thanks for your inputs. I apologize for the duplicate posts as i was not aware of the fact that, these forums are common. I will repeat these tests again and post the details if there are any issues! I would like to understand how we can decide that, there is Face Match ot No match based on PredictedLabel and confidence values? Let me know if there is any book, tutorial i need to study to understand this?. Please advice..

seetaram.nt gravatar imageseetaram.nt ( 2012-09-09 23:38:02 -0600 )edit

Hi,

I again tried the Facerec_demo.cpp example project. I just used few faces from the AT & T Database and my at.txt file looks some thing like this:facedb/s1/3.pgm;0 facedb/s1/8.pgm;0 facedb/s1/7.pgm;0 facedb/s1/6.pgm;0 facedb/s1/5.pgm;0 facedb/s1/4.pgm;0 facedb/s1/2.pgm;0 facedb/s1/1.pgm;0

I tried with 1.pgm, 2.pgm......8.pgm respectively as test image and i'm obseving confidence values, 2968 2432 2361 3037 2496 2458 2424 respectively... Now i tried with test image s2/1,pgm and getting confidence value as 2139..

I have the following questions and request you to kindly advice. 1. Can confidence value be used to find a match or no match? if yes then how to interpret these values for match and no match? else how ...(more)

seetaram.nt gravatar imageseetaram.nt ( 2012-09-12 00:09:14 -0600 )edit

What's the scale factor for confidence value?

fabioap.barbosa gravatar imagefabioap.barbosa ( 2014-11-14 04:21:23 -0600 )edit

@seetaram.nt Did u find answer for ur question.if yes,please share. Thanks

userfacerecognition gravatar imageuserfacerecognition ( 2015-03-06 01:31:47 -0600 )edit

Question Tools

Stats

Asked: 2012-09-07 04:09:53 -0600

Seen: 3,917 times

Last updated: Sep 08 '12