face-api.js
face-api.js copied to clipboard
create NetInput from base64 string
Hi, I'm trying do create a webservice to do face matching, so I'm writting code with textscript and express, I can get the picture in base64 but I'm trying to do a face matching but in the middle I don't know how to create a NetInput from base 64 string.
I tryied to create an Image but when I run I get this error: (node:10663) UnhandledPromiseRejectionWarning: Error: Image given has not completed loading
this is my code:
`const imgRef = faceapi.env.getEnv().createImageElement();
imgRef.src = 'image/jpeg;base64,'+rostros.referencia;
imgRef.width = 393;
imgRef.height = 574;
console.log("imgRef complete");
console.log(imgRef.complete);
console.log("about detectAllFaces");
const results = await faceapi.detectAllFaces(imgRef)
.withFaceLandmarks().withFaceDescriptors();
`
it's exactly what it says 'image has not completed loading' - assigning imgRef.src
is ok, but then execute actual detection inside event that triggers when image is loaded, something like imgRef.onload = () => faceapi.detectAllFaces(...)