npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-tesseract-scp

v0.0.1

Published

This plugin allows to recognise text from images

Downloads

2

Readme

Cordova Tesseract-OCR Plugin - For Android and iOS

This is a Cordova/Ionic plugin for OCR process using Tesseract library for both Android and iOS. Tesseract is an Open Source library for OCR (Optical Character Recognition) process.

This plugin defines a global TesseractPlugin object, which provides an API for recognizing text on images.

  TesseractPlugin.recognizeText(imageData, language, function(recognizedText) {
    deferred.resolve(recognizedText);
  }, function(reason) {
    deferred.reject('Error on recognizing text from image. ' + reason);
  });

Installation

Before installing this plugin, make sure you have added the platform for your app:

$ ionic platform add android

-> substitute android with ios to build for iOS.

-> substitute ionic with cordova to build on cordova.

1. Download or clone this project, copy it to your app root folder and run ionic command to add the plugin:

Ionic

$ git clone https://github.com/gustavomazzoni/cordova-plugin-tesseract
$ cp -rf cordova-plugin-tesseract your-project/cordova-plugin-tesseract
$ cd your-project/
$ ionic plugin add cordova-plugin-tesseract

Cordova

$ cordova plugin add https://github.com/gustavomazzoni/cordova-plugin-tesseract

2. For Android platform:

2.5 Your project is ready to use this plugin on Android platform. Build your project:

$ ionic build android

3. For iOS platform:

3.1 Inside root directory of your ios platform, create Podfile and add Tesseract OCR iOS (Tesseract library for iOS7+) as a dependency:

  • Create your-project/platforms/ios/Podfile
  • Add 'TesseractOCRiOS' dependency (replace 'ocr-translation' with the name of your project):
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'ocr-translation.xcodeproj/'

target 'ocr-translation' do

	pod 'TesseractOCRiOS', '4.0.0'

end

3.2 Still at your ios platform folder, install the dependencies (install the CocoaPods in case you don't have it yet) using the following commands:

$ pod install

3.3 Your project is ready to use this plugin on iOS platform. Build your project:

$ ionic build ios

Your project is ready to use this plugin.

Usage

cordova-plugin-tesseract is designed to recognize text in images in many languages, but for that to work we need to have the tessdata of the language you want the text to be recognized.

To use this plugin and recognize text in images, you need to:

1. Download the language

As soon as you enter on your OCR use case, call TesseractPlugin.loadLanguage function to download the tessdata for your language.

Language must be in format like eng . For a list of compatible languages check this link.

TesseractPlugin.loadLanguage(language, function(response) {
  deferred.resolve(response);
}, function(reason) {
  deferred.reject('Error on loading OCR file for your language. ' + reason);
});

2. Get image data from your photo

Load the image you want the text to be recognized from. On your angular Controller use $cordovaCamera or cordova-plugin-camera plugin to take the photo or load an image:

$cordovaCamera.getPicture(options).then(function(imageData) {
  $scope.image = "data:image/jpeg;base64," + imageData;
  $scope.text = null;

  $timeout(function() {
    // DOM has finished rendering
    // insert here the call to TesseractPlugin.recognizeText function to recognize the text
    
  });
}, function(err) {
  // error
  console.log('ERROR with camera plugin. Error: ' + err);
});

3. Recognize text from image

Then, after loaded the image, just call TesseractPlugin.recognizeText function with the image data, the language of the text in the image and a callback function to be called after the operation is done.

TesseractPlugin.recognizeText(imageData, language, function(recognizedText) {
  $scope.text = recognizedText;
}, function(reason) {
  console.log('Error on recognizing text from image. ' + reason);
});