问题
I am working on a project in which i should design an application which can detect all the faces of the persons passing by...I have a very large database comprising of several known people...I have used the EigenObjectRecognizer to recognize the image frame captured by the webcam...But the problem is sometimes it recognizes some persons wrongly....So if get the confidence value of this facial match...Then i can write a conditional loop so that if it is greater than 75%, then only detect him otherwise don't.Also I know that PCA based recognition is basic,I ll definitely move on to other new algorithms.But owing to the deadline of the project,I should submit it quickly....So please tell me how to get the confidence value of this EigenObjectRecognizer facial recognition....
回答1:
There is no exact confidence value however there is a variable scale that can be used and roughly interpreted as such which is the Eigen Distance.
The value that classifies as a good match changes according to the amount of data you have and the training parameters so you will have to test the values with different faces to work out your threshold.
You will have to add a function to the Eigen class to obtain this value. First we will overwrite the EigenObjectRecognizer we use. This is really simple loacte the file EigenObjectRecognizer.cs, it is locates in the \EMGU Installation directory\Emgu.CV or where ever you extracted the files you should be able to lacate it as it's in the same folder as the bin folder with all the .dlls you use.
Add the file to you project by right clicking on the project name in the solution explorer in visual studion and selecting Add>Existing Item... Navigate to the file and add it. Your project will automatically use this rather than the one held with EMGU.CV.dll in your references.
Open the EigenObjectRecognizer.cs now in your project, don't worry it's a copy of the original so any change you make won't effect the original source. To start of with make things easier by holding the Ctrl the pressing the m key followed by the o key this will collapse all method fields.
To start of with we need to overwrite the namespace I called mine Emgu.Custom.
Now at the top of the code add the following variable underneath the others
private float eigenDistance;
Add the following method to class,
/// <summary>
/// Get the calculated Eignen Distance for the last proceessed frame
/// </summary>
public float GetEignenDistance
{
get { return eigenDistance; }
}
You can place this anywhere you but obviously within the class and outside a method, now the important bit. We have made eigenDistance global but it's privately created when we call the .Recognize(Image image) method.
Find this method within EigenObjectRecognizer.cs and change
float eigenDistance;
to
eigenDistance = -1;
you could delete the float eigenDistance; line but I like to ensure it's overwritten with a value that I can observe for an error as it should always be positive if recognition has been applied correctly. You will notice that the following section of code includes:
FindMostSimilarObject(image, out index, out eigenDistance, out label);
- index
- eigenDistance
- label
Are all outputs available for use with a little extra coding.
We no need to point our Eigen recognizer variable to the write one:
Emgu.Custom.EigenObjectRecognizer recognizer;
We can now obtain the EigenDistance with this function call:
float EigenDistance = recognizer.GetEignenDistance;
Hope this clears things up,
Cheers,
Chris
来源:https://stackoverflow.com/questions/9457827/how-to-get-confidence-value-in-face-recognition-using-emgu-cv