react-native-vision-camera-ocr-plus
Version:
React Native Vision Camera plugin for on-device text recognition (OCR) and translation using ML Kit. Maintained fork of react-native-vision-camera-text-recognition
19 lines (17 loc) • 559 B
text/typescript
import { NativeModules, Platform } from 'react-native';
import type { PhotoOptions, Text } from './types';
export async function PhotoRecognizer(options: PhotoOptions): Promise<Text> {
const { PhotoRecognizerModule } = NativeModules;
const { uri, orientation } = options;
if (!uri) {
throw Error("Can't resolve img uri");
}
if (Platform.OS === 'ios') {
return await PhotoRecognizerModule.process(
uri.replace('file://', ''),
orientation || 'portrait'
);
} else {
return await PhotoRecognizerModule.process(uri);
}
}