aarongrider / vision-camera-ocr

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

Adds hook to allow easier usage of the plugin #9

Open markrickert opened 2 years ago

markrickert commented 2 years ago

I added a hook, similar to the one in vision-camera-code-scanner so you don't have to manually deal with all the frame processor worklet and javascript thread stuff yourself.

Now, you can just do:

import { useScanOCR } from "vision-camera-ocr";

// ...
const [frameProcessor, ocrData] = useScanOCR();
React.useEffect(() => {
  // This effect will run every time the frameprocessor gets different data.
  if (ocrData) {
    console.log('Got Data: ', ocrData);
  }
}, [ocrData]);

return (
  <Camera
    // ...
    frameProcessor={frameProcessor}
    frameProcessorFps='auto'
  />
)

I also fixed a typo in the readme usage section that should close #7