Skip to content

Instantly share code, notes, and snippets.

@supachaic
Created January 7, 2019 04:56
Show Gist options
  • Save supachaic/3f1cf413fd968bd50a4ffbcee6d1e2a5 to your computer and use it in GitHub Desktop.
Save supachaic/3f1cf413fd968bd50a4ffbcee6d1e2a5 to your computer and use it in GitHub Desktop.
Create Face Matcher
// 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