problem in face recognition from webcam
Hello, i have recently started working on face recognition using opencv c++. i am facing problem while recognizing unknown faces. Code works fine on known face but when i give unknown face it is giving true label when it false. Method which i am following is -
Taking the face images i.e, cropping it with using "detectMultiScale" for training using webcam.
Then training the dataset with 20 images of different expressions using EIgen. (tried with fisher & LBPH also.)
for recognition converting images to gray scale using everything according to opencv then Aligning images, Equalizing Histogram, detecting face using cascade classifier after that recognition using predict model.
Everything working fine on my face. but problem occurs while i am testing it on faces other than trained faces. It is showing my label to unknown face.
any lead will be welcome. Thanks in advance.
that is somewhat expected. it will just retrieve the closest from the db (identification task).
if you wanted to find out: "is that me or not ?" rather try the MACE algorithm, it was made for exactly that.
@berak thank you for the suggestion. but can we do something in the same algorithm to achieve more accuracy? if possible please let me know. as it MACE is not available on opencv 3.4.1
it simply cannot do that reliably.
sure, you can try to find a better threshold, or improve on the normalization (like aligning images, so the eyes are all on a horizontal line, and in the same place for each person) ,but there are limits to the algorithms there.
look out for other means, like the openface dnn (if you have color images), MACE, etc.
@berak thank you.. it is really helpful. i will try it. and once opencv 4.0 releases i will use MACE.
let me know, how it works!
@berak Another thing I would like to ask you that if we use other distance metrics (apart from Euclidean distance, like cosine distance and others) for getting thresholds for the images we are testing on, then can we get better results, if any ?
oh, indeed, that's a good idea. (e.g. HELLINGER instead of CHI_SQR for the LBPH recognizer) or cosine. or Mahalanobis for fisherfaces. also, replacing the nearest neighbour distance with an SVM or ANN gave some improvements. (att database can be solved 100% with BIF features & ANN)
but you'd have to hack into the src code for it, no wayto change it from the outside ;(
but again, you have to be specific about the problem, your "face recognition" is trying to solve.
an identification task,(like implemented in opencv's FaceRecognizer) will give nice results for known persons (that is, what it's meant to do) , but likely fail on "unknown"
an authentication task (me or not ?), like the MACE, might sometimes fail to recognize you, but it must NEVER let anyone else in. (and it does that pretty reliable)
then, there's also verification (2 images, do they show the same person ?) -- the dnn one might be very useful here. train a threshold (or an SVM) on "same or not".
@berak thanks for sharing it. it might be helpful and also thank you for ur all suggestions. i will go with openface and then with MACE.
@berak i have tested on mace algorithm. but i am not getting the accuracy which i want. it fails at different lightning conditions.