vision-camera-plugin-scan-faces
VisionCamera Frame Processor Plugin to detect faces using MLKit Vision Face Detector
Installation
yarn add vision-camera-plugin-scan-faces
Usage
Plugin initialization
//Configure VisionCamera
const PLUGIN_NAME = 'scanFaces';
const TARGET_FPS = 3;
const device = useCameraDevice('front');
const plugin = VisionCameraProxy.initFrameProcessorPlugin(PLUGIN_NAME);
const scanFaces = (frame: Frame): object => {
'worklet';
if (plugin == null) throw new Error(`Failed to load Frame Processor Plugin "${PLUGIN_NAME}"!`);
const result = plugin.call(frame);
console.log(result)
if (result && typeof result === 'object') {
return result;
}
throw new Error('Expected an object from the plugin call');
};
const frameProcessorScanFaces = useFrameProcessor((frame) => {
'worklet';
runAtTargetFps(TARGET_FPS, () => {
'worklet';
const faces = scanFaces(frame);
console.log(`Faces in Frame: ${JSON.stringify(faces, null, 2)}`);
//Work with faces here
});
}, []);
Vision Camera
<Camera
enableBufferCompression={false}
enableHighQualityPhotos={false}
pixelFormat='yuv'
hdr={false}
device={device}
photo
video={false}
frameProcessor={frameProcessorScanFaces}
{...otherCameraProps}
/>
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT