# #reactjs #react-native #ocr #image-recognition #firebase-mlkit
Вопрос:
у меня есть предстоящий проект, чтобы построить приложение, которое имеет какой-то символ признания в ней я выбрал реагировать Native с EXPO и mlkit и я следил за документацией, но я всегда получаю следующее сообщение об ошибке: необработанное отклонение (ошибку TypeError): невозможно прочитать свойства неопределены (значение ‘detectFromUri’) может кто-то помочь мне, я пытаюсь найти решение для дней,
import { View, Text, StyleSheet, Image, Button } from 'react-native'; import * as ImagePicker from 'expo-image-picker'; import MlkitOcr from 'react-native-mlkit-ocr'; function App() { // The path of the picked image const [pickedImagePath, setPickedImagePath] = useState(''); const [result,setResult] = useState(""); // This function is triggered when the "Select an image" button pressed const showImagePicker = async () =gt; { // Ask the user for the permission to access the media library const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (permissionResult.granted === false) { alert("You've refused to allow this appp to access your photos!"); return; } const result = await ImagePicker.launchImageLibraryAsync(); // Explore the result console.log(result); if (!result.cancelled) { setPickedImagePath(result.uri); console.log(result.uri); } } const finallyOcr = async () =gt; { const resultFromUri = await MlkitOcr?.detectFromUri(pickedImagePath);} // This function is triggered when the "Open camera" button pressed const openCamera = async () =gt; { // Ask the user for the permission to access the camera const permissionResult = await ImagePicker.requestCameraPermissionsAsync(); if (permissionResult.granted === false) { alert("You've refused to allow this appp to access your camera!"); return; } const result = await ImagePicker.launchCameraAsync(); // Explore the result console.log(result); if (!result.cancelled) { setPickedImagePath(result.uri); console.log(result.uri); } } return ( lt;View style={styles.screen}gt; lt;View style={styles.buttonContainer}gt; lt;Button onPress={showImagePicker} title="Select an image" /gt; lt;Button onPress={openCamera} title="Open camera" /gt; lt;/Viewgt; lt;View style={styles.imageContainer}gt; { pickedImagePath !== '' amp;amp; lt;Image source={{ uri: pickedImagePath }} style={styles.image} /gt; } lt;/Viewgt; lt;Button onPress={finallyOcr} title="OCR" /gt; lt;/Viewgt; ); } export default App; // Kindacode.com // Just some styles const styles = StyleSheet.create({ screen: { flex: 1, justifyContent: 'center', alignItems: 'center', }, buttonContainer: { width: 400, flexDirection: 'row', justifyContent: 'space-around' }, imageContainer: { padding: 30 }, image: { width: 400, height: 300, resizeMode: 'cover' } });```
Комментарии:
1.
MlkitOcr
возвращаетсяundefined