Tastenkunst / brfv5-browser

Beyond Reality Face SDK - BRFv5 - Platform: Browser
229 stars 48 forks source link

Tracking a single frame (image) #19

Open luispuig opened 4 years ago

luispuig commented 4 years ago

Hello,

We are using this solution for webcam video tracking. Currently, we have an extra need, processing an image using BRFv5 to get the 68 points. First, we transform the image to 640x480 pixels and we make sure that the face is centred and with good size. But:

Which configuration should we use?

I share an image as an example of face not detected.

image

// 640 x 480 
const BRF = await BRFv5.createInstance({ width, height, uniqueFrame: true });
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
context.drawImage(imageElement, 0, 0, width, height);
const imageData = context.getImageData(0, 0, width, height);

for (let index = 0; index < 10; index += 1) {
        BRF.Manager.update(imageData);
}

const faces = BRF.Manager.getFaces();

const isFaceDetected =
        faces.length > 0 &&
        (faces[0].state === BRF.Instance.BRFv5State.FACE_TRACKING_START ||
          faces[0].state === BRF.Instance.BRFv5State.FACE_TRACKING);

if (isFaceDetected) {
     return resolve(faces[0].vertices);
}
const error = new Error('No face detected');
error.code = 999;
return reject(error);