react-native-text-detector | Text Detector from image | Computer Vision library
kandi X-RAY | react-native-text-detector Summary
kandi X-RAY | react-native-text-detector Summary
Text Detector from image for react native using firebase MLKit on android and Tesseract on iOS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Detect features from a URI
- Converts the given firebase vision text into a map
- Create JS module modules
- Create native modules
- Create view managers
react-native-text-detector Key Features
react-native-text-detector Examples and Code Snippets
Community Discussions
Trending Discussions on react-native-text-detector
QUESTION
First, I used https://github.com/jeanpan/react-native-camera-roll-picker#readme to get an image from photo library, it returned a uri: ph://11A68DD6-A651-462D-BDAB-68FB853ED141/L0/001
Then, I used https://github.com/zsajjad/react-native-text-detector to get text from that image
It worked fine in android but it always returned false in iOS, and I found the following error in console log
NSURLConnection finished with error - code -1002
For more information, the image control can show that image correctly
Here is my source code : https://github.com/haison8x/react-native-test-ocr
Is there any problem with that URI or with application permission?
...ANSWER
Answered 2020-Jan-15 at 12:15Due to the sandbox policy of Apple https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html, your app cannot read the photo in gallery directly, it will encounter the error: NSURLConnection finished with error - code -1002.
Here is my approach:
- Use RNFS.copyAssetsFileIOS copy photo to temp file at your app documents
- Use react-native-text-detector to analyze that temp file
The full example is pushed to https://github.com/haison8x/react-native-test-ocr
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-text-detector
Import your tessdata folder (you can download one for your language from Google's Repo OR if that gives an error use THIS REPO as referenced on stack overflow as solution into the root of your project AS A REFERENCED FOLDER (see below). It contains the Tesseract trained data files. You can add your own trained data files here too.
Add following in ios/Podfile
Run following from project's root directory
Use <your_project>.xcworkspace to run your app
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-text-detector and add RNTextDetector.xcodeproj
In XCode, in the project navigator, select your project. Add libRNTextDetector.a to your project's Build Phases ➜ Link Binary With Libraries
Run your project (Cmd+R)<
Open up android/app/src/main/java/[...]/MainApplication.java
Add import com.fetchsky.RNTextDetector.RNTextDetectorPackage; to the imports at the top of the file
Add new RNTextDetectorPackage() to the list returned by the getPackages() method
Append the following lines to android/settings.gradle: include ':react-native-text-detector' project(':react-native-text-detector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-detector/android')
Insert the following lines inside the dependencies block in android/app/build.gradle: ... dependencies { implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'com.google.firebase:firebase-ml-vision:17.0.0' implementation (project(':react-native-text-detector')) { exclude group: 'com.google.firebase' } } // Place this line at the end of file apply plugin: 'com.google.gms.google-services' // Work around for onesignal-gradle-plugin compatibility com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Insert the following lines inside the dependencies block in android/build.gradle: buildscript { repositories { google() ... } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:4.0.1' // google-services plugin } }
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page