vision-camera-plugin-scan-faces
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

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

Package Sidebar

Install

npm i vision-camera-plugin-scan-faces

Weekly Downloads

0

Version

0.3.1

License

MIT

Unpacked Size

168 kB

Total Files

27

Last publish

Collaborators

  • dolakzdenek