git clone https://github.com/DavidStrausz/cordova-plugin-live-ocr.git
ionic plugin add cordova-plugin-live-ocr
ionic platform remove <platform>
ionic platform add <platform>
import { Cordova, Plugin } from 'ionic-native';
@Plugin({
pluginName: 'LiveOcrPlugin',
plugin: 'cordova-plugin-live-ocr',
pluginRef: 'LiveOcrPlugin',
repo: 'https://github.com/DavidStrausz/cordova-plugin-live-ocr',
platforms: ['Android', 'iOS']
})
export class LiveOcrPlugin {
@Cordova()
static recognizeText(successCallback, errorCallback): Promise
@Cordova() static loadLanguage(language, successCallback, errorCallback): any { } }
### Usage in project
* `loadLanguage()` is only required in android case, iOS version has a tessdata file integrated
```typescript
import {LiveOcrPlugin} from 'path/to/native/wrapper/LiveOcrPlugin';
this.platform.ready().then(() => {
//load language file for android (it is included for ios)
LiveOcrPlugin.loadLanguage(
'eng',
(success) => {
//success callback
},
(error) => {
//error callback
});
//start recognition process
LiveOcrPlugin.recognizeText(
(success) => {
//success callback
},
(error) => {
//error callback
});
});
cordova-plugin-live-ocr
, install the plugin again, add platforms - otherwise the dependencies of cordova-plugin-live-ocr
will be missingCocoapods must be set up (master repository)
Since iOS 10 it's mandatory to add a NSCameraUsageDescription and NSPhotoLibraryUsageDescription in the info.plist.
Optional when errors with bitcode occur while building:
platforms/ios
: Pods
-> Targets TesseractOCRiOS
-> Build Settings -> Select All
-> Search for bitcode
-> Enable Bitcode No
cordova-plugin-live-ocr/src/ios
can be modified (header and implementation):
AROverlayViewController
CaptureSessionManager
LiveOcrPlugin
cordova-plugin-live-ocr/src/android
:LiveOcrPlugin.java
OcrActivity.java
Path
path/to/tess-two
in terminalndk-build
(this takes a while, go drink a coffee).aar
file can be copied from project-folder/tess-two/build/outputs/aar
platforms/android
android/jniLibs/*
(only needed for builds)build.gradle (Module: android)
apply from: "cordova-plugin-live-ocr/<appid>-libs.gradle"
OcrActivity.java
(android/java/at.ventocom.liveocr.OcrActivity
)CaptureActivity
and hit alt + enter
to add a dependency on previously included OCRTest projectplatforms/android/OCRTest/build/outputs/aar/OCRTest-release.aar
and replace the existing one in cordova-plugin-live-ocr/lib
(don't forget to rename)