aarongrider / vision-camera-ocr

VisionCamera Frame Processor Plugin to detect text in real time using MLKit Text Detector (OCR)
MIT License
235 stars 86 forks source link

ScanOCR is returning `undefined` #14

Open mihailpozarski opened 1 year ago

mihailpozarski commented 1 year ago

Hi @aarongrider,

My project suddenly started to fail when attempting to OCR vision camera frames. It throws Frame Processor threw an error: Cannot read property 'result' of undefined... my code (removed all not related code to the issue):

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

const frameProcessor = useFrameProcessor(frame => {
  'worklet';
  const result = scanOCR(frame).result;
  if (result.text.length > 0) {
    runOnJS(processText)(result.text);
  }
}, []);

scanOCR(frame) is returning undefined instead of a OCR result... the weird thing is i haven't changed my code at all from when it was working.

I ran the example project on the repo and it has the same issue.

my dependencies:

"react-native": "0.70.0",
"react-native-reanimated": "^2.10.0",
"react-native-vision-camera": "^2.14.1",
"vision-camera-ocr": "^1.0.0",

my babel.config.js:

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

if you need the complete component code let me know. As im new to React Native I don't have the knowledge to check the library to find the issue

Thanks for the awesome library!

lightning331 commented 1 year ago

Still same to me. It works well on IOS but the result always get "undefined" on Android.