-
-
Notifications
You must be signed in to change notification settings - Fork 342
Embedding
To use face simmilaity compare feature, you must first enable face.embedding
module
and calculate embedding vectors for both first and second image you want to compare.
For example,
const myConfig = { face: { embedding: true }};
const human = new Human(myConfig);
const firstResult = await human.detect(firstImage);
const secondResult = await human.detect(secondImage);
const firstEmbedding = firstResult.face[0].embedding;
const secondEmbedding = secondResult.face[0].embedding;
const simmilarity = human.simmilarity(firstEmbedding, secondEmbedding);
console.log(`faces are ${100 * simmilarity}% simmilar`);
If the image or video frame have multiple faces and you want to match all of them, simply loop through all results.face
for (let i = 0; i < secondResult.face.length; i++) {
const secondEmbedding = secondResult.face[i].embedding;
const simmilarity = human.simmilarity(firstEmbedding, secondEmbedding);
console.log(`face ${i} is ${100 * simmilarity}% simmilar`);
}
Embedding vectors are calulated values uniquely identifying a given face and presented as array of 192 float values
They can be stored as normal arrays and reused as needed
Simmilarity function is based on Eucilidean distance between all points in vector
Eucilidean distance is a square root of sum of squared distances between each point in (each value in 192-member array)
Human Library Wiki Pages
3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition