/anyline-ocr-cordova-module

Anyline Cordova Module for iOS and Android

Primary LanguageJavaScriptOtherNOASSERTION

 _____         _ _         
|  _  |___ _ _| |_|___ ___ 
|     |   | | | | |   | -_|
|__|__|_|_|_  |_|_|_|_|___|
          |___|            

Anyline SDK Cordova Plugin

Anyline provides an easy-to-use SDK for applications to enable Optical Character Recognition (OCR) on mobile devices.

Anyline Cordova Plugin Documentation Resources

Update to >= 5.0

If you use this plugin with a equal or greater version then 5.0, you can use our new Anyline structure, which will provide the whole configuration of every SDK Feature through the config file. If you use the the 'scan' call in your Javascript files, you have to use a new config style. The old calls with the old configurations will still work.

Available Products

  • Barcode: Scan 23 types of international barcode & QR code formats.
  • Energy: Scan meter readings of various electric, gas, and water meters.
  • License Plate: Scan license plates of different sizes and from different countries.
  • Document: Detect document outlines, validate the angles of the document to ensure it is not too skewed, validates the document ratio, determine the sharpness of the text and rectifie the document.
  • ID: Reliable scanning of data from passports, Driving Licenses and IDs machine readable zones (MRZ)
  • Anyline OCR: Create a custom use case with LINE or GRID recognition

UWP

UWP is currently available in a Beta phase. You can use it with x86. Available products are: - Anyline OCR - Barcode - License Plate - MRZ

Requirements

Android

  • Android device with SDK >= 15
  • decent camera functionality (recommended: 720p and adequate auto focus)

iOS

  • minimum iOS 8
  • minimum iPhone4s
  • minimum Camera of 1080p
  • Cordova iOS v4.3.0 (Cocoapod support)

Quick Start - Setup

This is just a simple setup guide to integrate the anylinesdk-plugin in an existing Cordova project.
For more information about Cordova, how to use plugins, etc. see https://cordova.apache.org/.

1. Add the anylinesdk-plugin to your existing cordova project
cordova plugin add io-anyline-cordova

Or use plugman. E.g. for android:

plugman install --platform android --project platforms/android --plugin io-anyline-cordova

if you get this error:

Error: CocoaPods was not found. Please install version 1.0.1 or greater from https://cocoapods.org/

please install Cocoapods

If you'd like to clone the repository you will have to use git-lfs. Use the following commands to install git-lfs.

brew install git-lfs
git lfs install

If you prefer downloading a package, use the provided zip package on the releases page. Be aware that the github download zip button does not work for projects with git-lfs.

2. Plugin Usage
cordova.exec(onResult, onError, "AnylineSDK", "scan", config);
  • onResult: a function that is called on a scan result
  • onError: a function that is called on error or when the user canceled the scanning
  • AnylineSDK: add this string to make sure the anyline-sdk plugin is called
  • scanMode: "scan"
  • config: an array
    • config[0]: the license key
    • config[1]: the view config
OCR sample configuration

For more examples, check the example configurations.

[
  "YOUR_LICENSE_KEY",
  {
    "camera": {
      "captureResolution": "1080"
    },
    "flash": {
      "mode": "manual",
      "alignment": "bottom_right"
    },
    "viewPlugin": {
      "plugin" : {
        "id" : "OCR_VC",
        "ocrPlugin" : {
          "scanMode" : "AUTO",
          "languages" : ["www/assets/anyline_capitals.traineddata"],
          "charWhitelist": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          "validationRegex": "[A-Z0-9]{8}$",
          "minConfidence": 85

        }
      },
      "cutoutConfig": {
        "style": "rect",
        "maxWidthPercent": "80%",
        "maxHeightPercent": "80%",
        "alignment": "center",
        "width": 540,
        "ratioFromSize": {
          "width": 5,
          "height": 1
        },
        "strokeWidth": 2,
        "cornerRadius": 10,
        "strokeColor": "FFFFFF",
        "outerColor": "000000",
        "outerAlpha": 0.3,
        "feedbackStrokeColor": "0099FF"
      },
      "scanFeedback": {
        "style": "contour_point",
        "strokeWidth": 3,
        "strokeColor": "0099FF",
        "fillColor": "220099FF",
        "beepOnResult": true,
        "vibrateOnResult": true,
        "blinkAnimationOnResult": true
      },
      "cancelOnResult": true
    }
  }
]
3. Run your cordova project: Enjoy scanning and have fun :)

Checkout our online documentation for more details.

Known Issues

iOS

Error: data parameter is nil

This can happen, when the Cocoapod installation is not correctly linked. You can fix this by going into myCordovaApp/platforms/ios and run:

pod install

If Anyline was not installed via pods, please make sure that your Podfile (./platform/ios/Podfile) contains the following line within your build target:

pod 'Anyline', '~> 15.1’

Access to app denied | missing architectures

Please make sure that your XCode Project has the build setting "Valid Architectures" set. This has to be set in your Build Target and in the Pods build target.

Project Settings --> Build Settings --> Search for Valid Architecture --> Add the following value: "$(inherited) arm64 arm64e armv7 armv7s"

"VALID_ARCHS" = "$(inherited) arm64 arm64e armv7 armv7s"

Additional Functions

getLicenseExpiryDate

Check till when the provided License is or was valid. Returns a string.

cordova.exec(console.log, console.log, "AnylineSDK", "CHECK_LICENSE", [licenseKey]); // YYYY-MM-DD

License

See LICENSE file.