Ask Your Question
0

problem in face recognition from webcam

asked 2018-06-05 06:35:58 -0600

saniket123 gravatar image

updated 2018-06-05 06:46:12 -0600

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 -

  1. Taking the face images i.e, cropping it with using "detectMultiScale" for training using webcam.

  2. Then training the dataset with 20 images of different expressions using EIgen. (tried with fisher & LBPH also.)

  3. 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.

edit retag flag offensive close merge delete

Comments

but when i give unknown face it is giving true label

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 gravatar imageberak ( 2018-06-05 06:50:24 -0600 )edit

@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

saniket123 gravatar imagesaniket123 ( 2018-06-06 01:27:32 -0600 )edit

while recognizing unknown faces

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 gravatar imageberak ( 2018-06-06 01:40:19 -0600 )edit

@berak thank you.. it is really helpful. i will try it. and once opencv 4.0 releases i will use MACE.

saniket123 gravatar imagesaniket123 ( 2018-06-06 01:48:05 -0600 )edit

let me know, how it works!

berak gravatar imageberak ( 2018-06-06 01:54:25 -0600 )edit

@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 ?

saniket123 gravatar imagesaniket123 ( 2018-06-06 02:14:11 -0600 )edit

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 ;(

berak gravatar imageberak ( 2018-06-06 02:26:39 -0600 )edit

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 gravatar imageberak ( 2018-06-06 02:36:32 -0600 )edit

@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.

saniket123 gravatar imagesaniket123 ( 2018-06-06 02:51:16 -0600 )edit

@berak i have tested on mace algorithm. but i am not getting the accuracy which i want. it fails at different lightning conditions.

saniket123 gravatar imagesaniket123 ( 2018-07-02 01:26:47 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-06 02:46:14 -0600

berak gravatar image

not really an answer to your question, but you really should try the new, pretrained openface dnn:

dnn::Net net = dnn::readNetFromTorch("openface.nn4.small2.v1.t7");
Mat image = ... // color image !
Mat inputBlob = dnn::blobFromImage(image, 1./255, Size(96,96), Scalar(), true, false);
net.setInput(inputBlob);

Mat feature = net.forward().clone();

then just compare features from images, using either a straight L2 norm(like in the paper)

double dist = norm(feature1, feature2);

or any ml algorithm you like.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-05 06:35:58 -0600

Seen: 419 times

Last updated: Jun 06 '18