React Native On-Device Text Recognition w/ Google ML Kit
npm install @react-native-ml-kit/text-recognition --save
CLI autolink feature links the module while building the app.
react-native link @react-native-ml-kit/text-recognition
On iOS, use CocoaPods to add the native RNMLKitTextRecognition to your project:
npx pod-install
import TextRecognition from '@react-native-ml-kit/text-recognition';
const result = await TextRecognition.recognize(imageURL);
console.log('Recognized text:', result.text);
for (let block of result.blocks) {
console.log('Block text:', block.text);
console.log('Block frame:', block.frame);
for (let line of block.lines) {
console.log('Line text:', line.text);
console.log('Line frame:', line.frame);
}
}