dgopsq / react-native-barcodes-detector

Detect barcodes from static images in React Native using Google ML Kit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header

Detect different barcodes in static images directly on React Native. This library has a TypeScript-first support and uses Google ML Kit under the hood πŸ€–.

The supported barcodes are:

πŸ— Installation

# Install
npm install react-native-barcodes-detector

# Link
cd ios && pod install

⚑️ Usage

Take a look at the example to see a use-case with react-native-image-picker (it's really short, I promise πŸ™).

Anyway, this is the tl;dr:

import { detectBarcodes, BarcodeFormat } from "react-native-barcodes-detector";

// This is the local image url usually retrieved
// through libraries like `react-native-image-picker`.
const imageUrl = "file://..."

// The `detectBarcodes` function needs the image url and
// a list of formats to detect. Using an empty array all
// the supported formats will be used making the detection
// process slower 🐌.
const formats = [BarcodeFormat.QR_CODE]

detectBarcodes(imageUrl, formats)
  .then(barcodes => {
    // Here `barcodes` will contain a list
    // of detected barcodes.
  })

πŸ™‹ FAQ

Where is the detection process actually done?

This library uses Google ML Kit to recognize barcodes, and this process is completely done on the physical device.

Why I can't detect a Data Matrix code?

For a Data Matrix to be recognized it must intersect the center of the image, as stated here. This means that only one Data Matrix code can be recognized per image.

βš–οΈ License

React Native Barcodes Detector is under the MIT license.

About

Detect barcodes from static images in React Native using Google ML Kit.

License:MIT License


Languages

Language:Java 25.9%Language:Kotlin 19.9%Language:Swift 15.1%Language:Objective-C 14.7%Language:TypeScript 12.5%Language:JavaScript 6.0%Language:Ruby 5.4%Language:C 0.4%