Custom Quality Function¶
By default, the component automatically takes a picture when the built-in face detector picks up a suitable frame
It is possible to make custom function for determining the quality of the frame
-
Implement a quality function to find a suitable frame. It should take a single argument of type
ImageData
and returns aPromise
that resolves to aboolean
. If thisPromise
resolves totrue
then this frame can be used in the produced payloadconst customQualityFunction = async (imageData) => { const face = await SomeFaceDetector.detectFace(imageData); if (face.isValid()) { return true; } return false; };
-
Pass the quality function to the component
const idliveFaceCapture = document.querySelector('idlive-face-capture'); idliveFaceCapture.addEventListener('initialize', () => { idliveFaceCapture.setCustomQualityFunction(customQualityFunction); });
-
You can optionally import the version of the library without the built-in face detector, which is smaller than the standard version
import 'idlive-face-capture-web/index-no-detector';
Check out example