171
Support Optical Character Recognition (OCR)
J
James
Would be great if Expo can support OCR without requiring detaching.
The only I've found so far is https://github.com/jonathanpalma/react-native-tesseract-ocr which requires detaching from Expo (https://github.com/jonathanpalma/react-native-tesseract-ocr/issues/30).
Something along the line of
"onFacesDetected (function)
Callback invoked with results of face detection on the preview. It will receive an object containing:"
or
"onBarCodeRead (function)
Callback that is invoked when a bar code has been successfully read. The callback is provided with an Object of the shape { type: string, data: string }, where the type refers to the bar code type that was scanned and the data is the information encoded in the bar code (in this case of QR codes, this is often a URL)"
but perhaps
"onTextDetected (function) " with list of strings it detected, would be really awesome. :D
Noitidart
Michael Wood: Thanks for your inspiration and also then guidance on doing it myself. The library used there is Android only. Here is a more recently maintained (9 months ago) library and it doesn't need a patch - https://github.com/agoldis/react-native-mlkit-ocr
Here are the steps to take:
- expo init
- expo install react-native-mlkit-ocr expo-dev-client
- eas build -p all --profile development(follow the walkthough steps in command line)
- When the build completes, go to the build page on expo.io and then tap install, it opens a QR code
- Scan that QR code with your device, it will download the app to it.
- Start the downloaded app, it tells you what to do (I list what it says in steps 7 and 8)
- expo start --dev-client
- Take a picture of this QR code on the app you download in step 6
I used expo-camera, and takePhotoAsync and then fed it to
MlkitOcr.detectFromUri
and it worked beautifully on both iOS and Android. Major credit to authors of the library, it only has a few stars, please star it.Activity
Newest
Oldest
Filip Danielsson
any news on this? im not able to use react-native-camera because that requires changes to podfile (using managed with eas build)
Michael Wood
Here's an ugly proof of concept using EAS Build:
Have tried it on Android
Noitidart
Michael Wood: Thanks for your inspiration and also then guidance on doing it myself. The library used there is Android only. Here is a more recently maintained (9 months ago) library and it doesn't need a patch - https://github.com/agoldis/react-native-mlkit-ocr
Here are the steps to take:
- expo init
- expo install react-native-mlkit-ocr expo-dev-client
- eas build -p all --profile development(follow the walkthough steps in command line)
- When the build completes, go to the build page on expo.io and then tap install, it opens a QR code
- Scan that QR code with your device, it will download the app to it.
- Start the downloaded app, it tells you what to do (I list what it says in steps 7 and 8)
- expo start --dev-client
- Take a picture of this QR code on the app you download in step 6
I used expo-camera, and takePhotoAsync and then fed it to
MlkitOcr.detectFromUri
and it worked beautifully on both iOS and Android. Major credit to authors of the library, it only has a few stars, please star it.R
Ramesh Patel
Noitidart: Does this work without EAS build? We are using expo build.
R
Ramesh Patel
Michael Wood: Does this work without EAS build? We are using expo build.
Michael Wood
Ramesh Patel: No. You'll need to use EAS Build. Either build locally on your machine using
eas build --local ...
or build on Expo's build service (without --local
).If you want to use Expo's build service, you currently need to sign up for the priority plan, but they have said that they will have a free tier available in future. In the mean time, you can build on your own machine for free.
C
Caick Andrade Dias
Noitidart: Hey, thank you very much for your response, it helped me a lot! I'm getting this issue where it only works if I rotate my physical device 90deg (landscape), it won't recognize any text in portrait mode, I don't know if that's something to do with expo-camera or if I'm doing anything wrong... do you have any code example on github or something like that for me to check it out?
Chhin Vanchhai
i have been waiting the feature for long time
geekOgeek
yeah still waiting for it
Michael Wood
geekOgeek: Have a look at Config Plugins, EAS Build, Expo run commands, etc. That will likely allow you to use something like react-native-tesseract-ocr without ejecting.
See also Brent's message here for an example of how this works with react-native-fast-image
geekOgeek
Michael Wood: thanks
Joshua Wilkinson
Definitely need this!
Constantine
Would be cool!
App Foreseen
OCR is important!
AVS
I have needed this feature for so long
u
undefined undefined
this would be epic 🔥
Johannes Wicovsky
Would be awesome
Load More
→