Git Product home page Git Product logo

smartscanner-cordova's Introduction

SmartScanner Cordova

Cordova plugin for the SmartScanner Core library to scan MRZ, NFC and barcodes.

Installation

This plugin can be installed from NPM:

# Using npm
npm install @idpass/smartscanner-cordova

# Using yarn
yarn add @idpass/smartscanner-cordova

# Then let cordova know about the plugin
cordova plugin add @idpass/smartscanner-cordova

Usage

The plugin is available in the cordova.plugins object, which is the registry of all available plugins.

const { SmartScannerPlugin } = cordova.plugins;

MRZ scanning example:

const result = await SmartScannerPlugin.executeScanner({
  action: 'START_SCANNER',
  options: {
    mode: 'mrz',
    mrzFormat: 'MRTD_TD1',
    config: {
      background: '#89837c',
      branding: false,
      isManualCapture: true,
    },
  },
});

OCR scanning example:

const result = await SmartScannerPlugin.executeScanner({
  action: 'START_SCANNER',
  options: {
    mode: 'ocr',
    ocrOptions: {
      type: 'documentNumber',
      regex: '\\d{4} \\d{4} \\d{5}'
    },
    config: {
      background: '#89837c',
      branding: false,
      isManualCapture: false, //if true user will be required to tap the capture button
      showGuide: true, //values below will only be used when this is set to true
      xGuide: 0.8, //accepts values from 0.0 - 1.0. Offsets the guide horizontally based on percentage.
      yGuide: 0.5, //accepts values from 0.0 - 1.0. Offsets the guide vertically based on percentage.
      widthGuide: 150, //sets the guide width. Default is 150
      heightGuide: 40 //sets the guide height. Default is 40
    },
  },
});

NFC scanning example:

```js
const result = await SmartScannerPlugin.executeScanner({
  action: 'START_SCANNER',
  options: {
    mode: 'nfc-scan',
    config: {
      background: '#89837c',
      branding: false,
      isManualCapture: true,
    },
  },
});

Barcode scanning example:

const result = await SmartScannerPlugin.executeScanner({
  action: 'START_SCANNER',
  options: {
    mode: 'barcode',
    barcodeOptions: {
      barcodeFormats: [
        'AZTEC',
        'CODABAR',
        'CODE_39',
        'CODE_93',
        'CODE_128',
        'DATA_MATRIX',
        'EAN_8',
        'EAN_13',
        'QR_CODE',
        'UPC_A',
        'UPC_E',
        'PDF_417',
      ],
    },
    config: {
      background: '#ffc234',
      label: 'Sample Label',
    },
  },
});

Refer to the API Reference for more information about the available API options and the returned result.

Related projects

License

Apache-2.0 License

smartscanner-cordova's People

Contributors

arnellebalane avatar dependabot[bot] avatar haklyray avatar jlduragos avatar nicholemnl avatar pparreno avatar rjmangubat23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

athario marutifh

smartscanner-cordova's Issues

Plugin metadata changes

Current Behaviour

Plugin metadata still references files and package ID for the MLKit plugin.

Expected Behaviour

Plugin metadat should now reference the new SmartScanner files and package ID.

Steps to Reproduce the Problem

  1. npm install -D @idpass/smartscanner-cordova
  2. cordova plugin add @idpass/smartscanner-cordova
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-impactlabs-mlkit': CordovaError: Uh oh!

Context

Android 12 crash

java.lang.RuntimeException:
at android.app.ActivityThread.deliverResults (ActivityThread.java:5863)
at android.app.ActivityThread.handleSendResult (ActivityThread.java:5902)
at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2440)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8641)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)
Caused by: java.lang.NullPointerException:
at org.idpass.cordova.plugin.SmartScannerPlugin.onActivityResult (SmartScannerPlugin.java:79)
at org.apache.cordova.CordovaInterfaceImpl.onActivityResult (CordovaInterfaceImpl.java:160)
at org.apache.cordova.CordovaActivity.onActivityResult (CordovaActivity.java:368)
at android.app.Activity.dispatchActivityResult (Activity.java:8651)
at android.app.ActivityThread.deliverResults (ActivityThread.java:5856)

=====================================
Device : Samsung Galaxy Note20 Ultra
Android Version : Android 12 (SDK 31)

Improvement on MRZ scanner

  • change to nullable variable: can now scan French ID
  • change the rectangle to fit the whole ID
  • use only the bottom half of the ID to do the mrz reading
  • if checkdigits is wrong, make the scan valid if we scan twice in a row the same value
  • display a message when no Models and no internet connection
  • display a message when we are downloading the Models
  • try to download the models on installing the app
  • add the image in the result
  • tap to focus added
  • redirect to settings if the permissions are not available

Unable to run the app, kotlin is ok

Current Behaviour

Cannot cordova android run, although i already use android@9 to install androidx in dependency,
this https://github.com/dcendents/android-maven-gradle-plugin is not working because abandon ,
i already use https://github.com/idpass/smartscanner-capacitor aar for smartscannerlib-debug.aar and the release one, and the error from build gradle is :

  • What went wrong:
    Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.

Failed to calculate the value of task ':CordovaLib:compileDebugJavaWithJavac'
property 'options.generatedSourceOutputDirectory'.
Querying the mapped value of map(java.io.File property(org.gradle.api.file.
Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$F
ixedDirectory, (drive)\CordovaLib\build\generated\ap_generated_sources\debug\out)) org.g
radle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@64da764c) b
efore task ':CordovaLib:compileDebugJavaWithJavac' has completed is not supported

Expected Behaviour

Cannot cordova android run, although i already use android@9 to install androidx in dependency,
this https://github.com/dcendents/android-maven-gradle-plugin is not working because abandon ,
i already use https://github.com/idpass/smartscanner-capacitor aar for smartscannerlib-debug.aar and the release one, and the error from build gradle is :

  • What went wrong:
    Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.

Failed to calculate the value of task ':CordovaLib:compileDebugJavaWithJavac'
property 'options.generatedSourceOutputDirectory'.
Querying the mapped value of map(java.io.File property(org.gradle.api.file.
Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$F
ixedDirectory, (drive)\CordovaLib\build\generated\ap_generated_sources\debug\out)) org.g
radle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@64da764c) b
efore task ':CordovaLib:compileDebugJavaWithJavac' has completed is not supported

Steps to Reproduce the Problem

  1. cordova platform remove android
    cordova platform add [email protected]
  2. cordova run android
  3. use gradle 7.2
  4. add
    in cofig.xml

Context

  • Version: 1.0.0
  • Platform: android
  • Cordova version: 10.0.0
    Untitled

Possible improvement on MRZ app

  • add option to take photo of front and back of the idea

  • add a way to still take photo if mrz is not detected

  • add Guatemala, el salvador, burkinafaso special format

  • option to configure the size of the rectangle

  • option to add more text message ( maybe with condition )

  • rename the lib to scan document ID or something similar

  • change the cordova plugin to be secondary project in the same repo?

  • add capacitor plugin

  • keep in mind that we should be able to to add more plugin easily

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.