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 = _labels.at<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 !