vision-camera-ocr icon indicating copy to clipboard operation
vision-camera-ocr copied to clipboard

Adds hook to allow easier usage of the plugin

Open markrickert opened this issue 3 years ago • 0 comments

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

markrickert avatar Aug 16 '22 15:08 markrickert