Search code examples
python-3.xopencvface-recognitioneuclidean-distance

How to do face recognition using euclidean distance in python


I have a project where I need to include face recognition in it. I am referring to this article. This article is using open-face to get the face embeddings and its saving all the embeddings in a pickle file. Then its passing the face embeddings data to support vector machine which generates another pickle file. This file is later used to recognize and predict the face.

This has been working and is giving me more than 80% accuracy. But this article has not explained on how to calculate euclidean distance. This I needed for my own research work.

I can easily calculate euclidean distance between the face embedding of test image and face embeddings present in pickle file but I am not able to understand how to set the threshold value so that any distance more than that will be tagged as unknown.

Can anyone please point me to some article where this has been explained and I can follow up from there. I have tried searching many articles but didnt get much results on this. Please help. Thanks


Solution

  • You can build 2 ( normal ) distributions.

    1. distances between same person's faces
    2. distances between different faces

    Intersection of these distributuins will be the threshold.

    Small illustration: enter image description here