Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

Confidence values for all faces from FaceRecognizer?

asked 2013-08-28 04:23:51 -0500

Is it possible to get a list of confidence values against all faces trained in a face recognition model?

What I'd like to to is not just return the predicted label, but see a confidence level against a particular face/all faces in the dataset used to train the model so that I can identify the possibility of a specific person being in front of the camera.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-08-28 05:01:23 -0500

berak gravatar image

updated 2013-08-28 05:06:03 -0500

the current implementation does a single nearest neighbour search over all items in the traindb, and returns the label and the distance of the best match. that distance is inverse proportional to "confidence".

it you're willing to hack the library, it should not be too difficult to return a label<-->distance map as well

here's the resp. (original) code section from LBPH::predict() (contrib/src/facerec.cpp:836):

for(size_t sampleIdx = 0; sampleIdx < _histograms.size(); sampleIdx++) {
    double dist = compareHist(_histograms[sampleIdx], query, CV_COMP_CHISQR);
    if((dist < minDist) && (dist < _threshold)) {
        minDist = dist;
        minClass =<int>((int) sampleIdx);

so, once you got the distance for a db-sample, you could add it to a list(in the same order as the labels/images) or an id-dist map, and return it. that's the easy part.

unfortunately, since all this code is behind an interface, you've got to modify this as well, same for the other 2 facerecos(eigen/fisher).

alternatively, you could just paste the code to your own file, and use your own interface, no idea what's more adequate for you.

good luck, and happy hacking !

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2013-08-28 04:23:51 -0500

Seen: 2,000 times

Last updated: Aug 28 '13