Giter VIP home page Giter VIP logo

react-native-text-detector's Introduction

React Native Text Detector

npm

See it in action

Checkout these blog for

for example of this package.

Different libraries

Default branch uses Tesseract on iOS and Firebase ML Kit on android. Beside that we have 2 branches

For deciding between which one is better check this blog on Hearbeat by Fritz.ai

Getting started

$ npm install react-native-text-detector --save or yarn add react-native-text-detector

Manual installation

iOS

Attach Tesseract Languages you want to use in your app

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.

NOTE: This library currently requires the tessdata folder to be linked as a referenced folder instead of a symbolic group. If Tesseract can't find a language file in your own project, it's probably because you created the tessdata folder as a symbolic group instead of a referenced folder. It should look like this if you did it correctly:

alt text

Note how the tessdata folder has a blue icon, indicating it was imported as a referenced folder instead of a symbolic group.

Also add -lstdc++ if not already present
Using Pods (Recommended)
  1. Add following in ios/Podfile
    pod 'RNTextDetector', path: '../node_modules/react-native-text-detector/ios'
  1. Run following from project's root directory
    cd ios && pod install
  1. Use <your_project>.xcworkspace to run your app
Direct Linking
  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-text-detector and add RNTextDetector.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNTextDetector.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

This package uses Firebase ML Kit for text recognition on android please make sure you have integrated firebase in your app before started integration of this package. Here is the guide for Firebase integration.

  1. 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
  1. 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')
    
  2. 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
    
  3. 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
        }
    }
    

Usage

/**
 *
 * This Example uses react-native-camera for getting image
 *
 */

import RNTextDetector from "react-native-text-detector";

export class TextDetectionComponent extends PureComponent {
  ...

  detectText = async () => {
    try {
      const options = {
        quality: 0.8,
        base64: true,
        skipProcessing: true,
      };
      const { uri } = await this.camera.takePictureAsync(options);
      const visionResp = await RNTextDetector.detectFromUri(uri);
      console.log('visionResp', visionResp);
    } catch (e) {
      console.warn(e);
    }
  };

  ...
}

react-native-text-detector's People

Contributors

erickmaeda avatar perraid avatar slavikdenis avatar zsajjad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-text-detector's Issues

Attempt to invoke virtual method

 java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.tasks.Task com.google.firebase.ml.vision.text.FirebaseVisionTextRecognizer.processImage(com.google.firebase.ml.vision.common.FirebaseVisionImage)' on a null object reference
        at com.fetchsky.RNTextDetector.RNTextDetectorModule.detectFromUri(RNTextDetectorModule.java:49)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:237)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
        at java.lang.Thread.run(Thread.java:919)

Execution failed for task ':react-native-text-detector:verifyReleaseResources'

Execution failed for task ':react-native-text-detector:verifyReleaseResources'

I'm trying to generate the APK file and when it reaches 96%, this error, below, occurs. I could not find a solution and I need to urgently generate the update of the App. Has anyone gone through this and can point out a possible solution?

  • My versions

Android Studio version: 3.4
Gradle version: 5.1.1
react-native-cli: 2.0.1
react-native: 0.55.4
npm: 6.9.0

  • In my android/build.gradle I have:

dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.1.0'
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:4.+'
}

ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = '26.1.0'
googlePlayServicesVersion = "16.+"
firebaseVersion = "17.6.0"
}

  • In my ./app/build.gradle file, I have:

compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.rvm"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
...
}


### The error:

Task :react-native-text-detector:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-text-detector:verifyReleaseResources'.

1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
D:\src\RN\rn_rvm\node_modules\react-native-text-detector\android\build\intermediates\res\merged\release\values\values.xml:1785: error: resource android:attr/fontVariationSettings not found.
D:\src\RN\rn_rvm\node_modules\react-native-text-detector\android\build\intermediates\res\merged\release\values\values.xml:1786: error: resource android:attr/ttcIndex not found.
error: failed linking references.

React/RCTBridge.h file not found // ios

Hi, thanks for this great library.

I tried to implement this but with no luck.
To replicate:

  1. react-native init myApp then cd myApp.
  2. npm install react-native-text-detector --save
  3. added language file in the folder 'tessdata' in ios folder
  4. add 'pod 'RNTextDetector', path: '../node_modules/react-native-text-detector/ios' ' to podfile
  5. pod install.
  6. build the app with the file xcworkspace in Xcode.
  7. Got this error 'React/RCTBridge.h' file not found.
    It seems it happened in the file RNTextDetector.m in line 4.

Do you know how to solve this or what I have done wrong?

Thanks a lot for your help in advance.

App build fails if proguard is enabled

Your Environment

  • react-native-text-detector : 0.6.0
  • Platform: Android
  • React Native version : 0.57.7

Expected Behavior

App should build successfully

Actual Behavior

App build fails

Context

I use App Center for building my React Native App for Android. I have enabled proguard. My app build is failing. Here are the logs

Printing usage to [/Users/vsts/agent/2.144.0/work/1/s/android/app/build/outputs/mapping/release/usage.txt]...
Removing unused program classes and class elements...
Original number of program classes: 11336
Final number of program classes: 7771
Inlining subroutines...
Obfuscating...
Printing mapping to [/Users/vsts/agent/2.144.0/work/1/s/android/app/build/outputs/mapping/release/mapping.txt]...
Preverifying...
Unexpected error while performing partial evaluation:
Class = [com/google/android/gms/internal/zzcih]
Method = [zza(Ljava/lang/String;[Lcom/google/android/gms/internal/zzcob;[Lcom/google/android/gms/internal/zzcog;)[Lcom/google/android/gms/internal/zzcoa;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/internal/zzcob] (with 1 known super classes) and [java/lang/String] (with 2 known super classes))
Unexpected error while preverifying:
Class = [com/google/android/gms/internal/zzcih]
Method = [zza(Ljava/lang/String;[Lcom/google/android/gms/internal/zzcob;[Lcom/google/android/gms/internal/zzcog;)[Lcom/google/android/gms/internal/zzcoa;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/internal/zzcob] (with 1 known super classes) and [java/lang/String] (with 2 known super classes))
Warning: Exception while processing task java.io.IOException: java.lang.IllegalArgumentException: Can't find common super class of [com/google/android/gms/internal/zzcob] (with 1 known super classes) and [java/lang/String] (with 2 known super classes)
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

FirebaseMLHandler Error When Run

Hi,

Could you please inform me how to solve this issue, I don't have build error, but the exception raised when run

E/AndroidRuntime: FATAL EXCEPTION: FirebaseMLHandler
Process: com.testcamera, PID: 6933
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbgl;
at com.google.android.gms.internal.firebase_ml.zzjz.zzga(Unknown Source:7)
at com.google.android.gms.internal.firebase_ml.zzij.zzgd(Unknown Source:7)
at com.google.android.gms.internal.firebase_ml.zzij.call(Unknown Source:23)
at com.google.android.gms.internal.firebase_ml.zzhx.zza(Unknown Source:29)
at com.google.android.gms.internal.firebase_ml.zzhy.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(Unknown Source:5)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbgl" on path: DexPathList[[zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/base.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/lib/arm, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/base.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/com.testcamera-ohnPqi-wOoaVACf52FQ-KA==/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Build error

My build fails here:

Building and installing the app on the device (cd android && ./gradlew installDebug)...

Configure project :app
Could not find google-services.json while looking in [src/nullnull/debug, src
/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCol
lection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'
    .

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not resolve project :react-native-text-detector.
Required by:
project :app
> Unable to find a matching configuration of project :react-native-text-detector: None of the consumable configurations have attributes.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 38s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:611:11)
at Object.execFileSync (child_process.js:629:13)
at runOnAllDevices (/home/stefano/devel/ocr/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/home/stefano/devel/ocr/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/home/stefano/devel/ocr/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)

Build errors

Hello,
I am having some dependency issues while using this library. Can you let me know what are the requirements for this library to work on an android? I am working on a project built by someone else and previously, it was working properly. I believe the issues came after upgrading the targetSdkVersion to 29.

I get the following error when running on android.


In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.google.android.gms:play-services-vision:20.0.0 -> com.google.android.gms:play-services-vision-co
mmon@[19.0.2], but play-services-vision-common version was 19.1.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-ml-vision@{strictly 24.1.0}
-- Project 'app' depends onto com.google.android.gms:play-services-vision-common@{strictly 19.1.0}
-- Project 'app' depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.android.gms:play-services-vision-image-label@{strictly 18.0.4}
-- Project 'app' depends onto com.google.android.gms:play-services-vision@{strictly 20.0.0}


Please check the attached project level and app level gradle files.
Screenshot 2020-09-21 at 15 37 50
Screenshot 2020-09-21 at 15 43 09

Add typescript typings

It would be great if we could add simple typescript typings. Would you accept a PR? :)

Build Failure on missing TesseractOCR.h file

Compilation of RNtextDetector.m fails on the error:

.../node_modules/react-native-text-detector/ios/RNTextDetector.m:8:9: 'TesseractOCR/TesseractOCR.h' file not found

This occurs for both the Pods Approach and the Direct Linking/manual approach. In addition, adding the TesseractOCRiOS pod and attempting to reference the header files through the Build Settings/Header Search Paths did also not work.

Android app crashes on startup: com.google.android.gms.internal.zzdls not found

I have followed the instruction in the README.md, added the google-services.json file.
When I run my app, I can see from the Android Studio debugger this error:

E/AndroidRuntime: FATAL EXCEPTION: FirebaseMLHandler
                  Process: com.businesscards, PID: 17600
                  java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzdls

And the app just crashes. I have googled the error, cleaned and rebuild the project, but the error is still there. What's happening?
Could that be the gradle version?

my package.json contains

...
  "dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-camera": "^1.2.0",
    "react-native-text-detector": "^0.0.5"
  },
...

I use

  • com.android.tools.build:gradle:3.1.3 and
  • Android SDK Build Tools 27.0.3

Unable to build App after latest google library release

I get the following error when I build the app:

` ....1\android\app\src\debug\AndroidManifest.xml:22:18-91 Error:
       Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
       is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
       Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger. 

I found out that this was due to update Google Play Services and Firebase . This forces to use androidx dependencies causing most of dependent builds to fail.

Thanks to comments in : facebook/react-native#25301

Whether anyone working on a fix for this issue?

**iOS issues**

after pod install when i try to run the application its show this error

dyld: lazy symbol binding failed: can't resolve symbol ___cxa_guard_acquire in /Users/mds/Library/Developer/CoreSimulator/Devices/1DF42AC9-39F7-464C-949F-35A71DF058F5/data/Containers/Bundle/Application/6DA21693-67E4-4976-9718-BB23A7A2D6F2/MyCarAuction.app/MyCarAuction because dependent dylib #1 could not be loaded

IOS Compile Issue

Im developing app with ios 12. But I got below error in xcode. Also I got error react-native . I examined issue and saw libstdc lib not supportted for ios 12. But i wanna use react-native-text-detector. How to solve this issue ?

ld: building for iOS Simulator, but linking in dylib built for macOS, file '/usr/lib/libstdc++.6.0.9.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

receiving only the bounding information, but no text

When ever there is Text on the picture the result of detectFromUri is a list which looks like this:

[{"bounding": {"height": 35.99999999999981, "left": 69, "top": 35.000000000000064, "width": 171.99999999999997}}, {"bounding": {"height": 36.00000000000009, "left": 907, "top": 55.99999999999992, "width": 207.99999999999991}}, {"bounding": {"height": 26.000000000000036, "left": 38, "top": 97.99999999999994, "width": 152}}, {"bounding": {"height": 24.00000000000025, "left": 149, "top": 363.99999999999994, "width": 112.00000000000003}}, {"bounding": {"height": 21.9999999999999, "left": 173, "top": 389.99999999999994, "width": 64}}, {"bounding": {"height": 30.999999999999922, "left": 831, "top": 336.00000000000006, "width": 177.00000000000003}}, {"bounding": {"height": 50, "left": 245, "top": 452.00000000000006, "width": 540.9999999999999}}, {"bounding": {"height": 54.000000000000135, "left": 424, "top": 562.9999999999999, "width": 314}}, {"bounding": {"height": 51.99999999999979, "left": 336, "top": 655.0000000000002, "width": 483.99999999999994}}, {"bounding": {"height": 52.00000000000007, "left": 342, "top": 851, "width": 471.99999999999994}}, {"bounding": {"height": 53.99999999999986, "left": 398, "top": 943, "width": 362}}, {"bounding": {"height": 54.000000000000135, "left": 332, "top": 1033, "width": 494.00000000000006}}, {"bounding": {"height": 53.99999999999986, "left": 408, "top": 1125, "width": 342.00000000000006}}, {"bounding": {"height": 29.000000000000135, "left": 309, "top": 1260.9999999999998, "width": 538}}, {"bounding": {"height": 41.000000000000256, "left": 271, "top": 1429, "width": 629.0000000000001}}, {"bounding": {"height": 25, "left": 50, "top": 1590, "width": 85}}, {"bounding": {"height": 26.000000000000036, "left": 415, "top": 1589, "width": 339.00000000000006}}, {"bounding": {"height": 25, "left": 1030, "top": 1590, "width": 84.99999999999996}}, {"bounding": {"height": 36.00000000000009, "left": 399, "top": 1741, "width": 369}}, {"bounding": {"height": 40.99999999999998, "left": 107, "top": 2298, "width": 79.99999999999999}}, {"bounding": {"height": 31.999999999999957, "left": 29, "top": 2372, "width": 237}}, {"bounding": {"height": 30.999999999999922, "left": 392.99999999999994, "top": 2373, "width": 94.00000000000006}}, {"bounding": {"height": 25, "left": 635, "top": 2372, "width": 191.0000000000001}}, {"bounding": {"height": 33.9916022841783, "left": 982.2541148807525, "top": 2370.0083977158215, "width": 80.62109506214296}}]

If there is no characters in the picture the result looks like this:
{"error": "On-Device text detection failed with error: Something went wrong"}

which also does not play nicely with the presenting logic borrowed from some other examples which goes like this:
state.textRecognition.map( (item: { text: string }, i: number) => ( <Text key={i} style={[styles.subtitle, { color: colors.text }]}> {item.text} </Text> ))

Am I doing something wrong?

trouble dependency

it's truly great, but now I'm facing trouble facing dependency in firebase while I've more installed another package, one say is play-service-vision (I used that on react-native-camera) and I just excluded that and facing another one for base and auth

below is my android/app/build.gradle file

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.xxx"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }

        multiDexEnabled true

    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release

        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation(project(":react-native-google-signin")){
        exclude group: "com.google.android.gms" // very important
    }
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation (project(':react-native-text-detector')) {
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-vision'
    }
    implementation project(':react-native-select-contact-android')
    implementation project(':react-native-firebase')
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation "com.google.firebase:firebase-ads:15.0.1"
    implementation "com.google.firebase:firebase-auth:16.0.2"
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-share')

    implementation project(':react-native-image-picker')
    implementation project(':react-native-bottom-sheet-behavior')
    implementation project(':react-native-svg')
    implementation project(':react-native-navigation')

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation (project(':react-native-camera')) {
        exclude group: "com.google.android.gms"
    }
}
// apply plugin: "com.google.gms.google-services"
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'

and this is my android/build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
// apply plugin: 'com.google.gms.google-services'

def googlePlayServicesVersion = '15.0.1'

allprojects {
    repositories {
        configurations.all {
            resolutionStrategy {
                // react-native-admob
                force "com.google.android.gms:play-services-ads:$googlePlayServicesVersion"
                // react-native-maps
                force "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
                force "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
                // react-native-onesignal
                force "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
                force "com.google.android.gms:play-services-analytics:$googlePlayServicesVersion"
                force "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
                force "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
                //force "com.google.android.gms:play-services-places:$googlePlayServicesVersion"
                // react-native-google-sign-in
                force "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
                // ml kit
                force "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
                // force "com.google.android.gms:play-services-vision-common:15.0.2"
            }
        }
        mavenLocal()
        maven {url "https://maven.google.com"}
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url "https://jitpack.io" }
    }
}

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

This is the error

> The library com.google.android.gms:play-services-auth-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 15.1.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.1,16.0.1], [16.0.3,16.0.3]], but resolves to 16.0.3. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Thanks

must the picture taken in landscape to get the text

I tried to take the picture of ID card vertically and horizontally, the results is taken horizontally will have a more accurate results.
however vertically taken picture, the text returned are literally all wrong (random text returned or non at all)

'FirebaseCore/FirebaseCore.h' file not found ios

I want to use the firebase version of the library, but I can't get to build the project, always get some errors.

I created my project with expo like: expo init myproject
Installed the firebase version of this module: npm install git+https://github.com/zsajjad/react-native-text-detector.git#firebase
Then ejecting it: expo eject
Changing the directory to ios and creating Podfile: pod init

Added these lines to the Podfile:
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'React', :path => '../node_modules/react-native'
pod 'RNTextDetector', path: '../node_modules/react-native-text-detector/ios'

Then updating and installing the pods with: pod update, pod install

Opening the myproject.xcworkspace file and adding GoogleService-Info.plist and finally tried to build it, but got this error:

RNTextDetector.m
#import <FirebaseCore/FirebaseCore.h> <= 'FirebaseCore/FirebaseCore.h' file not found

And I see some other errors as well, in the RNTextDetector > RCTBridgeModule.h:

typedef struct RCTMethodInfo { <= Redefinition of 'RCTMethodInfo'

What do I miss ?

Tesseract branch: App crashes on using RNTextDetector.detect

I'm trying the tesseract branch on android using the example given in the Readme but the app crashes as soon as the detect method is called. The app crashes without giving any error message and running 'react-native log-android' shows nothing either.

RNTextDetector detectFromUri doesn't return detected text

I've managed to get this library built and running on my device and I have my tessdata folder referenced correctly as described in the readme. RNTextDetector.detectFromUri seems to be detecting text, however the detect text isn't provided in the visionResp, only the bounding and position data for the detected text. Is there something else I need to do to get the text?

I've implemented the usage of RNTextDetector.detectFromUri based off of the BusinessCard sample project.

https://github.com/zsajjad/BusinessCard/blob/master/app/App.js#L98

Here are screenshots of the app and what is logged to the console.
image

image

edit: I've also tried getting much clearer photos than the example, and that hasn't worked either.

Cannot read property 'detectFromUri' of undefined

My app can be builded.

But when I activate the detectFromUri function, it shows it is undefined.

And also, I see the console, RNTextDetector is undefined after import this module.

How to solve this issue?

detectFromUri works fine in android but it returns false in iOS

I used https://github.com/jeanpan/react-native-camera-roll-picker#readme to get the image from photo library, it returned uri: ph://11A68DD6-A651-462D-BDAB-68FB853ED141/L0/001

Unfortunately, detectFromUri always returns false and show the following error in console:
NSURLConnection finished with error - code -1002

However, the Image Control can show the image with that uri .

Here is my source code : https://github.com/haison8x/react-native-test-ocr

Failing to build project after installation

Hi there,

I followed the instructions from the README. I am using the following setup.

Using Pods (Recommended)
Add following in ios/Podfile
    pod 'RNTextDetector', path: '../node_modules/react-native-text-detector/ios'
Run following from project's root directory
    cd ios && pod install
Use <your_project>.xcworkspace to run your app

After I did the above and built the project in xCode I got the following error

linker command failed with exit code 1 (use -v to see invocation

Has anyone experienced this error when setting up using Pods?

issue

Screenshot_20200525-174151

Kindly help me out asap

RNTextDetectorModule

whatsapp image 2018-10-06 at 3 00 38 am

Hi,
I tried to implement this but not working at my end.
To replicate:

react-native init myApp then cd myApp.
npm install react-native-text-detector --save

It seems it happened in the file RNTextDetectorModule.java in line 51.

Task result =
line 51: this.detector.processImage(image)

error on iOS

clang: error: no such file or directory: '/Users/Macbook/Library/Developer/Xcode/DerivedData/CRANE-ciqqhizauxjmlaevomkjkiypelyu/Build/Products/Debug-iphonesimulator/libRNTextDetector.a'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.