rodgomesc / vision-camera-ocr

VisionCamera Frame Processor Plugin that uses MLKit Text Recognition API to recognize text in any Latin-based character set
MIT License
19 stars 5 forks source link

Frame Processor threw an error: Cannot read property 'result' of undefined #4

Closed mihailpozarski closed 2 years ago

mihailpozarski commented 2 years ago

Hi @rodgomesc,

My project suddenly started to fail when attempting to OCR vision camera frames. It threw 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.

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.

Thanks for the awesome library!

mihailpozarski commented 2 years ago

Sorry! this has nothing to do with your plugin