Different result when finding the similarity between 2 pictures of 1 person in LBPH by changing the order of prediction (Bug #4437)


Added by Quang Huy Nguyen over 9 years ago. Updated over 9 years ago.


Status:New Start date:2015-06-25
Priority:High Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Affected version:2.4.9 (latest release) Operating System:Android
Difficulty:Easy HW Platform:ARM
Pull request:

Description

I use LBPH face recognizer to find the similarity between 2 pictures of 1 person (one pics took in light condition and the other took in dark condition).
I know that in LBPH, the number of pics in training set doesn't matter as FisherFaces or EigenFaces.
So, I use pic 1 as base image, and pic 2 as the training set. When I train (pic2), then predict (pic1), the result is 105
Next, I use pic 2 as base image, and pic 1 as the training set. When I train (pic1), then predict (pic2), the result is 85

Meanwhile, I expect that the both of the 2 experiments must produce the same result.

Digging further in the source code, I find out that LBPH predict function use the function: compareHist( InputArray _H1, InputArray _H2, int method ). In this function, the LBPH assign the third parameter as: CV_COMP_CHISQR which is one of 4 method of comparing 2 histograms (CV_COMP_CORREL, CV_COMP_CHISQR, CV_COMP_INTERSECT, CV_COMP_BHATTACHARYYA)

I thought the problem is the formula of CV_COMP_CHISQR itself: http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.html

In this formula, if I consider HISTOGRAM of pic 1 as H1, and HISTOGRAM of pic 2 as H2, the result of d(H1, H2) will be different from d(H2, H1)

So my suggestion is in order to avoid this, can you guy repare the compareHist in LBPH predict function to use CV_COMP_CORREL method. Thus, we can ensure that d(H1, H2) = d(H2, H1) and lead to predict(pic1) = predict(pic2).

Besides, I'm using opencv android sdk 2.4.11. It's great if somebody can fix this and regenerate the jar file for opencv android sdk.

Thanks!


History

Updated by be rak over 9 years ago

I use LBPH face recognizer to find the similarity between 2 pictures of 1 person

this already sounds like a bad idea. opencv's facerecognizer classes are for face identification (nearest item in database), not for face verification (same/not-same)
for the latter, you will need a fundamentally different approach, like learning a threshold on difference images. for more elaborate schemes, look e.g. [here](http://vis-www.cs.umass.edu/lfw/results.html)

I know that in LBPH, the number of pics in training set doesn't matter as FisherFaces or EigenFaces.

this is clearly wrong. though LBPH does not build a global model, you still need a couple of images to improve the 1-nearest-neighbour search.

(one pics took in light condition and the other took in dark condition).

so, it's pretty obvious, that due to the sparsity of of your trainset, it prefers a different person with the same lighting conditions. again, you need pose and lighting normalization preprocessing to eliminate this (and ofc. more images).

Meanwhile, I expect that the both of the 2 experiments must produce the same result.

a wrong assumption.

I thought the problem is the formula of CV_COMP_CHISQR itself

there you at least got a point, imho. CV_COMP_CHISQR is indeed asymmetric.
but if you do real tests for the identification task (like a 10-fold cross-validation) you will still find, that is more accurate than the more symmetric CV_COMP_CHISQR_ALT, and that your proposed CV_COMP_CORREL method fares worst of all.

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/5040

Also available in: Atom PDF