I'm working on some facial recognition scripts in python using the dlib library. dlib takes in a face and returns a 128 dimension tuple with floating point values representing the values for key points in the face. To determine if two faces are the same I'll take both of there 128 dimension descriptors and calculate the Euclidean distance. If its less than .6 they are likely the same.

So, the question is how should I store these 128 floating point values so that I can later search them quickly?

I don't think a sql db would be good because there isn't really a structure to the data and the speed gained by a nosql db would be valuable.

The problem really is that I can't seem to devise a way to store the data so that you can use the db to filter the query. There is no select * from faces where euclidean_distance({{ all 128 values }}) < .6 sooo...any ideas?

  • Are you able to limit the search at all? By nose shape, eye shape, etc? Otherwise, everytime you are looking for a match, it has to do a full scan. If you can't restrict the search space (maybe as a first attempt?) then the answer by @riddler is the best one. If you are able to restrict the search space then a relational database is your best bet. nosql usually works best for key/value searches where you look up by key. Looking up by value (or parts of a value) is going to be slow, no matter what you have providing storage. – Jonathan Fite Aug 2 '18 at 14:35

Any sort of storage would work as long as the 128D values can be retrieved and loaded back as a vector.

The Euclidean distance is a computed value. You would retrieve the 128D descriptor of all faces in the database. For each face, compute the Euclidean distance between it and the unknown face.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.