React Native wrapper for OCR functionality of https://developers.google.com/ml-kit/
As of the moment, this only supports Android.
$ npm install git+https://github.com/xtrycatchx/react-native-mlkit-ocr.git --save
$ react-native link react-native-ml-kit-ocr
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-ml-kit-ocrand addRNMlKitOcr.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNMlKitOcr.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNMlKitOcrPackage;to the imports at the top of the file - Add
new RNMlKitOcrPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-ml-kit-ocr' project(':react-native-ml-kit-ocr').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ml-kit-ocr/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-ml-kit-ocr')
import RNMlKitOcr from 'react-native-ml-kit-ocr';
const pathOfImage = `the_path_of_your_image_to_extract`
RNMlKitOcr.detect(pathOfImage).then(result => {
// do something with the data
console.log(JSON.parse(result))
})