Coder Social home page Coder Social logo

changegamers / cordova-plugin-mlkit-barcode-scanner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mobisysgmbh/cordova-plugin-mlkit-barcode-scanner

3.0 1.0 3.0 26.15 MB

A Cordova barcode scanning plugin based on the Google Mobile Vision library for iOS & Android.

License: MIT License

Objective-C 39.31% JavaScript 6.80% Java 46.94% CSS 5.38% HTML 1.57%

cordova-plugin-mlkit-barcode-scanner's Introduction

๐Ÿ“ท cordova-plugin-mlkit-barcode-scanner

Purpose of this Project

The purpose of this project is to provide a barcode scanner utilizing the Google ML Kit Vision library for the Cordova framework on iOS and Android. The MLKit library is incredibly performant and fast in comparison to any other barcode reader that I have used that are free.

Plugin Dependencies

Dependency Version Info
cordova-android >=8.0.0
cordova-ios >=4.5.0
cordova-plugin-androidx ^3.0.0 If cordova-android <= 9.0.0
cordova-plugin-androidx-adapter ^1.1.3

Prerequisites

If your cordova-android version is below 9.0.0, you have to install cordova-plugin-androidx first beforce installing this plugin. Execute this command in your terminal:

cordova plugin add cordova-plugin-androidx

Installation

Run this command in your project root.

cordova plugin add cordova-plugin-mlkit-barcode-scanner

Supported Platforms

  • Android
  • iOS/iPadOS

Barcode Support

1d formats Android iOS
Codabar โœ“ โœ“
Code 39 โœ“ โœ“
Code 93 โœ“ โœ“
Code 128 โœ“ โœ“
EAN-8. โœ“ โœ“
EAN-13 โœ“ โœ“
ITF โœ“ โœ“
MSI โœ— โœ—
RSS Expanded โœ— โœ—
RSS-14 โœ— โœ—
UPC-A โœ“ โœ“
UPC-E โœ“ โœ“
2d formats Android iOS
Aztec โœ“ โœ“
Codablock โœ— โœ—
Data Matrix โœ“ โœ“
MaxiCode โœ— โœ—
PDF417 โœ“ โœ“
QR Code โœ“ โœ“

โ„น๏ธ Note that this API does not recognize barcodes in these forms:

  • 1D Barcodes with only one character
  • Barcodes in ITF format with fewer than six characters
  • Barcodes encoded with FNC2, FNC3 or FNC4
  • QR codes generated in the ECI mode

Usage

To use the plugin simply call cordova.plugins.mlkit.barcodeScanner.scan(options, sucessCallback, failureCallback). See the sample below.

cordova.plugins.mlkit.barcodeScanner.scan(options, (error, result) => {
  if (error) {
    // Error handling
  }

  // Do something with the data
  alert(result);
});

Plugin Options

The default options are shown below. Note that the detectorSize value must be a float. If the values are greater than 1 then they will not be visible on the screen. Use them as decimal percentages to determine how large you want the scan area to be. All values are optional.

const defaultOptions = {
  types: {
    Code128: true,
    Code39: true,
    Code93: true,
    CodaBar: true,
    DataMatrix: true,
    EAN13: true,
    EAN8: true,
    ITF: true,
    QRCode: true,
    UPCA: true,
    UPCE: true,
    PDF417: true,
    Aztec: true
  },
  detectorSize: 0.6
}

Output/Return value

result: {
  cancelled: boolean;
  text: string;
  format: string | undefined;
  type: string | undefined;
}

Run the test app

Install cordova

npm i -g cordova

Go to test app

cd test/scan-test-app

Install node modules

npm i

Prepare Cordova

cordova platform add android && cordova plugin add ../../ --link --force

Build and run the project Android

cordova build android && cordova run android

and iOS

cordova build ios && cordova run ios

Known Issues

Under unknown circumstances, an error may occur where the camera is upside down. Here is a list of devices that have this problem:

  • Zebra MC330K (Manufacturer: Zebra Technologies, Model: MC33)

cordova-plugin-mlkit-barcode-scanner's People

Contributors

flobiwankenobi avatar forrestmid avatar gordeev1 avatar h4ck-root avatar khayargoli avatar star-collector avatar zaucy avatar zisiszaverdas avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.