face-api.js icon indicating copy to clipboard operation
face-api.js copied to clipboard

create NetInput from base64 string

Open innovacion-novitech opened this issue 3 years ago • 1 comments

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();

`

innovacion-novitech avatar May 04 '21 07:05 innovacion-novitech

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(...)

vladmandic avatar May 04 '21 13:05 vladmandic