Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example is not working properly #29

Open
dongseobb opened this issue Sep 13, 2023 · 1 comment
Open

Example is not working properly #29

dongseobb opened this issue Sep 13, 2023 · 1 comment

Comments

@dongseobb
Copy link

dongseobb commented Sep 13, 2023

I've been using a camera before, and I'm going to introduce vision-camera-ocr for a new function.
But I tried to follow the example, but it didn't work.

If you run like this, runOnJS says it can't find it, but it doesn't work.

What is the problem and how do I solve it?

[package information]

  • react-native-vision-camera : 3.0.0
  • vision-camera-ocr : 1.0.0
  • react-native-reanimated : 3.5.1
  • react-native-worklets-core : 0.2.0

[code]


import {Camera, useCameraDevices, useFrameProcessor} from 'react-native-vision-camera';
import {runOnJS} from 'react-native-reanimated'
import { OCRFrame, scanOCR } from 'vision-camera-ocr';


const App = () => {
  const camera = useRef<any>(null); // 카메라 화면
  const devices = useCameraDevices();
  const device = devices.back; // 후면 카메라 사용
  const [ocr, setOcr] = React.useState<OCRFrame>();

  const frameProcessor = useFrameProcessor((frame) => {
    'worklet';
    const data = scanOCR(frame);
    runOnJS(setOcr)(data);
  }, []);

  ...

  return(
    <Camera
      ref={camera}
      style={{
        height: '100%',
        width: windowWidth,
      }}
      device={device}
      isActive={showCamera}
      photo={true}
      fps={240}
      frameProcessor={frameProcessor}
    />
  )
}

[babel.config.js]

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    ['babel-plugin-styled-components'],
    [
      'react-native-reanimated/plugin',
      {
        globals: ['__scanOCR'],
      },
    ],
  ],
};
@dlato97
Copy link

dlato97 commented Nov 15, 2023

this package only work with react-native-vision-camera v2.
If you want to use the packege whit version 3 see #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants