valstu / vision-camera-resize-plugin

A VisionCamera Frame Processor plugin for fast buffer resizing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚠️ work in progress! ⚠️

vision-camera-resize-plugin

A VisionCamera Frame Processor Plugin for fast buffer resizing.

By resizing buffers to a smaller resolution, you can achieve much faster frame processor executions than by running AI on a full-sized (4k) buffer.

Installation

npm install vision-camera-resize-plugin
cd ios && pod install

Add the plugin to your babel.config.js:

module.exports = {
  plugins: [
    [
      'react-native-reanimated/plugin',
      {
        globals: ['__resize'],
      },
    ],

    // ...

Note: You have to restart metro-bundler for changes in the babel.config.js file to take effect.

Usage

import { resize } from "vision-camera-resize-plugin";

// ...

const frameProcessor = useFrameProcessor((frame) => {
  'worklet';
  if (frame.width > 1920) {
    frame = resize(frame, 1920, 1080)
  }
  // run AI on smaller buffer here
}, []);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

A VisionCamera Frame Processor plugin for fast buffer resizing

License:MIT License


Languages

Language:Objective-C 33.6%Language:TypeScript 18.3%Language:Java 17.7%Language:JavaScript 17.2%Language:Ruby 11.2%Language:C 1.2%Language:Swift 0.9%