Tesseract OCR Plugin for Cordova
Before installing the plugin to your project, you need to do a few things:
- Copy the
contents of the libs
folder toplatforms/android/libs
directory of your Cordova project - Copy the
tessdata
folder toplatforms/android/assets
directory of your Cordova project - Instal the plugin using
cordova plugin add http://github.com/phoenixtwister/cordova-juleskelly-tesseract.git
Add this code on the deviceready
event of your project. This takes time on your first run of your application.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
tesseractOCR.load(function (callback) {
// your code here
}
}
Whenever you want to scan the text on your image, you have to pass the image path to the recognizeImage
method.
tesseractOCR.recognizeImage(imageURL, function (result) {
// the result argument stores the recognized text
});
This plugin uses Tess-Two Tesseract Tools for integrating it for Android [https://github.com/rmtheis/tess-two/tree/master/tess-two]
This plugin is only for Android. More platforms will be supported soon.