Face recognition, different results for same image

asked 2014-10-01 16:38:41 -0600

colegu gravatar image


I am working on a face recognition project. These are the pre-processing steps I use:
1. crop the face from the original image using lbpcascade_frontalface.xml (this will result in a square image)
2. convert the image to grayscale
3. resize the image to a fixed size (50, 50)

After this I use the images resulted to train a LBPH face recognizer. From my tests it seems that the recognizer returns a confidence that represents the best match between the tested image and another image in the training set(please correct me if I'm wrong). I tried training the model with 15 images and then trained it with only the best matching image and I got the same exact confidence in both cases.

To verify the accuracy I tried this: I took an image, used it for training. Cropped the image manually in gimp(the face is not affected by the crop). And I tested the original image against the cropped image and only got a confidence of 42.48...(the range seems to be between 0..100, identical images giving 0.0 as a result, so I'm not sure if it's good to have a big confidence or not, either way 42 is in the middle so the confidence is not very good). I argue that the confidence should be very good since the faces in the images are identical.

I observe 2 problems here:

1. After pre-processing, the 2 resulting images were not the same. Even though the face in the images was exactly the same, after pre-processing, one image had the face cropped more than the other(you could see more chin and forehead). the differences were not big, but observable, even on a 50x50 image. Again, I argue that the rectangle of the face detection should have been exactly the same. Please tell me if I'm doing something wrong or if I could improve this in any way.

2. The recognizer didn't work very well, even though the image was exactly the same but it was cropped differently. I did read the basic principles of lbp before starting this project and I understand why it would have problems with images that are cropped differently, but this is a big issue since there will always be differences in cropping(for instance if you open your mouth, your face will be bigger so the cropping will be different). Again, If you have any suggestions on how to improve this, please tell me.

I use the default values for the "train", "predict" and "detectMultiScale" methods. Maybe this is something that I could improve, but I'm not sure how.

Note. This is probably not important, but I use java with opencv on an Ubuntu machine.

edit retag flag offensive close merge delete



the 'confidence' value is actually a distance, so smaller==better

berak gravatar imageberak ( 2014-10-02 00:44:00 -0600 )edit

thanks for that, I was really not sure. I think I saw somewhere that the confidence was inverse proportional to the distance and I got confused. Also, when I tested with the face database unprocessed, I got values in the 80-90 range and I thought they were a point of reference. Could you please tell me another thing. Is the confidence the smallest value from the trained images? Or is it an average of some sort?

colegu gravatar imagecolegu ( 2014-10-02 01:46:40 -0600 )edit

smallest value to the trained images (or say, distance to the best found train image)

"I use java with opencv " - would that be javacv ? (3rd party api actually)

berak gravatar imageberak ( 2014-10-02 01:54:54 -0600 )edit

did you align the faces, because it effects the recognition . if you didn't you should detect the eyes then besed on this result you crop, rotate and resize the face for best results

chebhou gravatar imagechebhou ( 2014-10-02 03:05:20 -0600 )edit

no, I don't use javacv, I built the jar from opencv 2.4.9 and for FaceRecognizer I used a tutorial written by you I think

colegu gravatar imagecolegu ( 2014-10-02 03:28:45 -0600 )edit

@chebhou: I do plan to align the faces, but right now I tested with the exact same face, the alignment is exactly the same, but the face is cropped differently...

colegu gravatar imagecolegu ( 2014-10-02 03:59:42 -0600 )edit