Face recognition - Get distance for all trained images

asked 2013-05-12 01:01:59 -0500

MH gravatar image

updated 2013-05-12 01:14:11 -0500


I have just begun using OpenCV in the past week and i am hoping to get a little advice :).

I am currently using the FaceRecognizer to train a set of images and then use predict to compare a face against that trained set of images. This appears to be working fine, however it only retrieves the label with the best score whereas I was hoping to be able to retrieve the score and label for each trained image.

So say i have trained 10 images, i then have an image i want to compare against that trained set of images. My ideal output would be.

img1, distance

img2, distance

img3, distance


Is this possible?

Im not sure if it makes a big difference but i want to use each technique available and test the results. So Eigenfaces, Fisherfaces and LBP

So essentiall what im doing is.

Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
model->train(images , labels);
int predictedLabel;
double distance;
model->predict(testSample , predictedLabel , distance);

And essentially what i want is an array of labels and array of distance returned. Which isn't how it works haha.

edit retag flag offensive close merge delete


what do you want to do with that information ?

a real database won't have 10 images, more like 1000, so you'll pretty soon find out, that only the best result matters.

berak gravatar imageberak ( 2013-05-12 04:34:30 -0500 )edit

That's just an example, i do have a large database of images. I am doing a study where i require all of the results. And in real life if you have a large database it is possible to have multiple images with very close scores. So if that's the case the close matches should then be displayed to the user to allow them to decide.

MH gravatar imageMH ( 2013-05-12 06:50:26 -0500 )edit

ah, ok. that would be more a knn-search instead of the current nearest neighbour one

maybe this related question helps

berak gravatar imageberak ( 2013-05-12 08:46:12 -0500 )edit

Yeah that does seem to be what i am looking for!, i shall give it a go when i get home.

Thanks for that, it's very helpful :)

MH gravatar imageMH ( 2013-05-12 08:59:56 -0500 )edit