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

Property '__scanOCR' doesn't exist #15

Closed vitzaoral closed 1 year ago

vitzaoral commented 1 year ago

Hi, i am trying to get start with video-camera-ocr project, but with no luck. When I wan't to use scanOCR(frame) function, I always get error: Property '__scanOCR' doesn't exist. I am using yarn to install.

versions:

iOS: 16.0.3
xCode: 14.0.1

my dependencies:

"react-native": "0.70.3",
"react-native-reanimated": "^2.11.0",
"react-native-vision-camera": "^2.15.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', '__labelImage', ],
            },
        ],
    ],
}

Whole error:

Property '__scanOCR' doesn't exist

ReferenceError: Property '__scanOCR' doesn't exist
    at scanOCR (/Users/Developer/test/node_modules/vision-camera-ocr/src/index.tsx (49:7):1:33)
    at scanOCR (native)
    at _f (/Users/Developer/test/components/ScanScreen.js (36:45):1:77)
    at _f (native)
    at _f (/Users/Developer/test/node_modules/react-native-vision-camera/src/hooks/useFrameProcessor.ts (28:21):1:425)
    at _f (native)

reanimated::REAIOSErrorHandler::raiseSpec()
    REAIOSErrorHandler.mm:18
reanimated::ErrorHandler::raise()::'lambda'()::operator()()
decltype(static_cast<reanimated::ErrorHandler::raise()::'lambda'()&>(fp)()) std::__1::__invoke<reanimated::ErrorHandler::raise()::'lambda'()&>(reanimated::ErrorHandler::raise()::'lambda'()&)
void std::__1::__invoke_void_return_wrapper<void, true>::__call<reanimated::ErrorHandler::raise()::'lambda'()&>(reanimated::ErrorHandler::raise()::'lambda'()&)
std::__1::__function::__alloc_func<reanimated::ErrorHandler::raise()::'lambda'(), std::__1::allocator<reanimated::ErrorHandler::raise()::'lambda'()>, void ()>::operator()()
std::__1::__function::__func<reanimated::ErrorHandler::raise()::'lambda'(), std::__1::allocator<reanimated::ErrorHandler::raise()::'lambda'()>, void ()>::operator()()
std::__1::__function::__value_func<void ()>::operator()() const
std::__1::function<void ()>::operator()() const
invocation function for block in vision::VisionCameraScheduler::scheduleOnUI(std::__1::function<void ()>)
C663D847-B94F-3FB0-9254-32EDBC55315E
C663D847-B94F-3FB0-9254-32EDBC55315E
C663D847-B94F-3FB0-9254-32EDBC55315E
C663D847-B94F-3FB0-9254-32EDBC55315E
C663D847-B94F-3FB0-9254-32EDBC55315E
_pthread_wqthread
start_wqthread

I tried just clone example from this repository, same problem... I tried other preprocessors (for example Image labeler and it's OK).

Thank you.

sumi-svmx commented 1 year ago

did you you try running this command? react-native start -- --resetCache

vitzaoral commented 1 year ago

Yes, many times šŸ™‚ I tried just clone example project, run it with npm, yarn..no luck...maybe it is cause by XCode version (14.0.1). I've read many other forums where they describe a similar error and some have been helped by downgrading Xcode to version 13. But I haven't tried this.

vitzaoral commented 1 year ago

So I figured it up. It seems it isn't fault of this package but problem of the Vision camera package and Xcode version 14. One workaround could be downgrade Xcode to version 13. Or you can follow this thread.

In Xcode workspace, find FrameProcessorPlugin.h file and replace line 56:

__attribute__((constructor)) static void VISION_CONCAT(initialize_, objc_name)() \

with

+(void)load \

Built project, it works šŸ™‚

frabanca commented 1 year ago

I've had the same issue on a project with the following dependencies and I've resolved clearing metro cache with this guide: https://facebook.github.io/metro/docs/troubleshooting/

"dependencies": {
    "expo": "~48.0.15",
    "react": "18.2.0",
    "react-native": "0.71.7",
    "react-native-camera": "^4.2.1",
    "react-native-reanimated": "~2.14.4",
    "react-native-vision-camera": "^2.15.4",
    "typescript": "^4.9.4",
    "vision-camera-ocr": "^1.0.0",
    ....
  },