All Projects → mrousavy → vision-camera-resize-plugin

mrousavy / vision-camera-resize-plugin

Licence: MIT License
A VisionCamera Frame Processor plugin for fast buffer resizing

Programming Languages

objective c
16641 projects - #2 most used programming language
typescript
32286 projects
java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language
swift
15916 projects

⚠️ 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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].