ismaelsousa / vision-camera-ocr

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

Slow down performances #14

Closed pepperav closed 5 months ago

pepperav commented 5 months ago

Hello @ismaelsousa, I'd like to thank you for supporting this project. I added it to my app and I am glad to you about the constant maintenance that you do frequently.

I recently upgraded from visioncamera 3.6.4 and ismaelsousa/vision-camera-ocr 2.1.1 to visioncamera 3.9.0 with ismaelsousa/vision-camera-ocr 2.2.3.

Well, unfortunately, the same code on the same Android phone (no issues on iPhone) I saw a deep slowing performaces when calling

const scannedOcr = scanOCR(frame);

Basically everything starts to lag and run slowly!

I've also tested with ismaelsousa/vision-camera-ocr 2.3.0 but without success.

What has changed so much to have such an impact on responsiveness?

ismaelsousa commented 5 months ago

hi, I put how to solve this here #9

I didn't test it again to see if how now the vision camera is working fine with the runAsync function but you can always modify in the native side

pepperav commented 5 months ago

Thank you for the quick reply 🙂

I did the refactor suggested by you on #9

  /** Process camera frames */
  const frameProcessor = useFrameProcessor(
    (frame) => {
      'worklet'

      runAsync(frame, () => {
        'worklet'
        /** Scanner */
        runAtTargetFps(10, () => {
          'worklet'

          /** Scan text */
          const text: TextDataMap = scanText(frame, { language: 'latin' })
          console.log(text)
        })
      })
    },
    [scanData],
  )

plus babel.js config, and I get a strange error:

Frame Processor Error: Exception in HostFunction: java.lang.ClassNotFoundException: Didn't find class "com.facebook.jni.MapIteratorHelper" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/product/lib64, /system/lib64, /system/product/lib64]], js engine: VisionCamera

Any tips here?

EDIT: Updating react-native-worklet-core to 0.3.0it was fixed and also the lag! 🎊 Thank you @ismaelsousa and keep going on! 💪

ismaelsousa commented 5 months ago

cool 😎