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
Wodin: 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.dev 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.Mr. M
Today in 2023, does this function not exist?
Ajay Singh
Mr. M: did you used "detectFromUri" , Did it worked ?
Mohammed Islam Zouagui
Noitidart where is the config plugin part or the Native config part ????
Wodin
Mohammed Islam Zouagui:
react-native-mlkit-ocr
includes native code, but does not need a config plugin. Not all native dependencies need a config plugin.It will not work in Expo Go, because Expo Go does not include the necessary native code, but if you create a development build after installing
react-native-mlkit-ocr
it will include the necessary native code.So you should just install the dependency and create a development build and use that instead of Expo Go.
Noitidart
Wodin: Thanks Michael!
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)
Wodin
Here's an ugly proof of concept using EAS Build:
Have tried it on Android
Noitidart
Wodin: 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.dev 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
Wodin: Does this work without EAS build? We are using expo build.
Wodin
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?
Isabela Bueno
Noitidart: Hello! Could you provide an example on how you were able to use the expo camera? I've read this method only accepts ImagePicker object but I've had no success with it. Thanks!
Chhin Vanchhai
i have been waiting the feature for long time
geekOgeek
yeah still waiting for it
Wodin
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
Wodin: thanks
Joshua Wilkinson
Definitely need this!
Constantine
Would be cool!
App Foreseen
OCR is important!
AVS
I have needed this feature for so long
Load More
→