Reputation: 1790
It might be an easy question but i am bit confuse so hope some one guide me properly.
i am using face recognition library of openCV libfacerec , it gives good result but i need to estimate the percentage of similarity. If i use unknown image as an input then still it predict as if the person exist in the system on the basis of last distance value
if(dist < minDist) {
minDist = dist;
minClass = _labels[sampleIdx];
}
I need to define some threshold and then validate/invalidate the user picture based on that threshold against some percentage or distance value, does any one know how to do that using libfacerec library because in this library there is no public variable to see distance or percentage value? Otherwise do i need to code inside the library for it because as far as i understand it does not contain this feature???
Upvotes: 3
Views: 5896
Reputation: 3797
Please make sure you are working on the latest revision! The latest revision of libfacerec allows you to get a predicition AND a confidence value for the prediction. You can see the signature of the methods here:
It is shown in the demo application I ship with the library, please see:
It's as simple as calling:
FaceRecognizer::predict(InputArray src, int &label, double &confidence);
on a computed model. So in your application you would simply write:
Mat testSample; // of course this is set somewhere in your application
int predictedLabel = -1;
double confidence = 0.0;
model.predict(testSample, predictedLabel, confidence);
Then you have the predicted label in predictedLabel AND the confidence value for this prediction in confidence.
Second, and this probably fits your question even more, you now have the possibility to set a threshold, below which an input image is regarded as unknown. You can either set the threshold in the constructor of a model or with a setter/getter method:
It is also shown in the demo application I ship with the library:
Upvotes: 5