0.1.3 • Published 2 years ago

vision-camera-plugin-capture v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vision-camera-plugin-capture

A tiny VisionCamera Frame Processor Plugin to capture a video frame.

  • JPEG/PNG format
  • Currently, supports iOS only

Installation

npm install vision-camera-plugin-capture

Setup

Frame Processors require react-native-reanimated 2.2.0 or higher. Also make sure to add

import 'react-native-reanimated';

to the top of the file when using useFrameProcessor.

Add this to your babel.config.js.

[
  'react-native-reanimated/plugin',
  {
    globals: ['__captureVideoFrame'],
  },
];

Usage

import 'react-native-reanimated';
import { useFrameProcessor } from 'react-native-vision-camera';
import { captureVideoFrame } from 'vision-camera-plugin-capture';

// ...

const frameProcessor = useFrameProcessor((frame) => {
  'worklet';
  const value = captureVideoFrame(frame, {
    format: 'JPEG',
  });

  if (value) {
    console.log(value.base64);
  }
}, []);

License

MIT