Created
January 7, 2019 04:56
-
-
Save supachaic/3f1cf413fd968bd50a4ffbcee6d1e2a5 to your computer and use it in GitHub Desktop.
Create Face Matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// face.js code... | |
const maxDescriptorDistance = 0.5; | |
export async function createMatcher(faceProfile) { | |
// Create labeled descriptors of member from profile | |
let members = Object.keys(faceProfile); | |
let labeledDescriptors = members.map( | |
member => | |
new faceapi.LabeledFaceDescriptors( | |
faceProfile[member].name, | |
faceProfile[member].descriptors.map( | |
descriptor => new Float32Array(descriptor) | |
) | |
) | |
); | |
// Create face matcher (maximum descriptor distance is 0.5) | |
let faceMatcher = new faceapi.FaceMatcher( | |
labeledDescriptors, | |
maxDescriptorDistance | |
); | |
return faceMatcher; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment