Thanks with your lib.
How do you get the descriptor array?
I see you have 68 face points. how do you use it?
I am very grateful if you can answer.
Thank you and your lib.
PART 1 - Setting up the source image ( The face you want to compare with )
Extract the descriptors using chain of methods. Consider it as source image.
const sourceImageResult = await this.faceapi.detectSingleFace(imageElement, faceDetectionOptions)
.withFaceLandmarks()
.withFaceDescriptor()
Create face matcher for the results of source image:
let faceMatcher = new faceapi.FaceMatcher(sourceImageResult)
Draw that image on canvas if you want by resizing and drawing functions from examples.
PART 2 - Comparing the target face with source face using descriptors
Extract the descriptors using chain of methods. Consider it as Target image.
const targetImageResult = await this.faceapi.detectSingleFace(imageElement, faceDetectionOptions)
.withFaceLandmarks()
.withFaceDescriptor()
Use the facematcher here with target image descriptors:
let bestmatch = faceMatcher.findBestMatch(targetImageResult.descriptor)
bestmatch is a JSON object containing distance (between source and target) and label
Note: While using the methods for detecting face, keep an eye on what you are using ( detectSingleFace OR detectAllFaces ), because detectSingleFace will give you single object with result and detectAllFaces will give you array of object of result.
So if you use *detectAllFaces *, while using faceMatcher.findBestMatch, you can use descriptors using map array function like this resizeResults.map(det => det.descriptor)[0] or you can loop on it.
thanks with your answer. But, that i want to know is method get descriptors.
can you help me ?
faceapi
.detectSingleFace(imageElement, faceDetectionOptions)
.withFaceLandmarks()
.withFaceDescriptor()
returns face descriptor object
- Thank you very much for your answers even though it's not what I needs. maybe it's because I don't show the question clearly.
-My question : I want to know how to calculate the final result as an array of descriptor values.
I think, you are confused, 68 face landmarks it's different to 128 Float32Array face descriptor, what do you do? what it is you application?
I think, you are confused, 68 face landmarks it's different to 128 Float32Array face descriptor, what do you do? what it is you application?
how to get from a face to an array of descriptions. I don't know how this code executes the sequence:
聽const resultsRef = await faceapi.detectAllFaces (referenceImage, faceDetectionOptions)
聽聽聽聽.withFaceLandmarks ()
聽聽聽聽.withFaceDescriptors ()
I think there must be a way to calculate it to produce that description and that's what I want to know.
Thank you for your interest and help me.
Besides from what @imtiyazs and @punisher97 already explained to you, await faceapi.detectAllFaces(img, faceDetectionOptions).withFaceLandmarks() .withFaceDescriptors() returns an array of prediction, where each element has a property descriptor, which holds the descriptor array.
How do you get the descriptor array?
I see you have 68 face points. how do you use it?
Or is the question rather, how the descriptors are computed and how they relate to the 68 face landmark points?
The face landmarks are computed on the extracted face image obtained based on the bounding boxes predicted by the face detector. Based on the 68 points, the bounding boxes are adjusted to be centered on the face. Then from the aligned face image the face recognition net predicts the face descriptors (under the hood it calls faceapi.computeFaceDescriptors(alignedImg)).
In this article I explained everything in more detail: https://itnext.io/face-api-js-javascript-api-for-face-recognition-in-the-browser-with-tensorflow-js-bcc2a6c4cf07
thank you very much.
It really helped me better understand this.
Most helpful comment
Besides from what @imtiyazs and @punisher97 already explained to you,
await faceapi.detectAllFaces(img, faceDetectionOptions).withFaceLandmarks() .withFaceDescriptors()returns an array of prediction, where each element has a property descriptor, which holds the descriptor array.Or is the question rather, how the descriptors are computed and how they relate to the 68 face landmark points?
The face landmarks are computed on the extracted face image obtained based on the bounding boxes predicted by the face detector. Based on the 68 points, the bounding boxes are adjusted to be centered on the face. Then from the aligned face image the face recognition net predicts the face descriptors (under the hood it calls
faceapi.computeFaceDescriptors(alignedImg)).In this article I explained everything in more detail: https://itnext.io/face-api-js-javascript-api-for-face-recognition-in-the-browser-with-tensorflow-js-bcc2a6c4cf07