Giter Site home page Giter Site logo

mirhat / react-native-documentscanner-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andreluisjunqueira/react-native-document-scanner-android

0.0 0.0 0.0 15.35 MB

Document scanner android, feature live detection, auto-capture, perspective correction :vibration_mode: :camera: -- :trophy:

License: MIT License

JavaScript 0.16% Python 0.02% Java 99.78% Makefile 0.05%

react-native-documentscanner-android's Introduction

enter image description here

React Native module to auto scan documents (Android only)

Live document detection library. Returns either a URI of the captured image, allowing you to easily store it or use it as you wish !

Features:

  • Live detection
  • Perspective correction and image crop
  • Flash

Get started

npm install --save react-native-documentscanner-android

In MainApplication.java, add this Line import com.documentscanner.DocumentScannerPackage; at the top of file,

@Override
protected  List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new  MainReactPackage(),
    new  DocumentScannerPackage() <--- this  line,
    ...
  );
}

IMPORTANT - Go to folder app/settings.gradle and add

include ':react-native-documentscanner-android'
project(':react-native-documentscanner-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-documentscanner-android/android')

Add this (don't forget)

include ':openCVLibrary310'
project(':openCVLibrary310').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-documentscanner-android/android/openCVLibrary310')

In android/app/src/main/AndroidManifest.xml

Change manifest header to avoid "Manifest merger error". After you add xmlns:tools="http://schemas.android.com/tools" should look like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.<yourAppName>" xmlns:tools="http://schemas.android.com/tools">

Add tools:replace="android:allowBackup" in <application tag. It should look like this:

<application tools:replace="android:allowBackup" android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme">

Add Camera permissions request:

<uses-permission android:name="android.permission.CAMERA" />

Add this to android/app/build.gradle (dependencies section)

implementation project(':react-native-documentscanner-android')

Usage

import DocumentScanner from 'react-native-documentscanner-android';

class YourComponent extends Component {
  render() {
    return (
      <View>
        <DocumentScanner
          onPictureTaken={data => {
            console.log(data.path);
          }}
          enableTorch={false}
          detectionCountBeforeCapture={5}
        />
      </View>
    );
  }
}

Properties

Props Default Type Description
manualOnly false bool if true, auto-detect is disabled
enableTorch false bool Allows to active or deactivate flash during document detection
detectionCountBeforeCapture 15 number Number of correct rectangle to detect before capture document
brightness 10 number This property only work to enhance document at the save moment
contrast 1 number This property only work to enhance document at the save moment
noGrayScale false bool Currently this module saves pictures only in gray scale, this property adds the option to disable gray scale

Manual capture

  • Get the component ref

<DocumentScanner ref={(ref) => this.scanner = ref} />

  • Then
this.scanner.capture();

Returned Image

Prop Params Type Description
onPictureTaken data object Returns an image in a object { path: ('imageUri')}
onProcessing data object Returns an object `{processing: (true

The images are saved in Documents folder.

Todo

  • Pass overlay color dynamically
  • Pass contrast and brightness to preview
  • Use front cam
  • Use base64

Contributors are welcome !!

Inspired in android project

react-native-documentscanner-android's People

Contributors

andreluisjunqueira avatar armin23615 avatar erickmaeda avatar guihendias avatar thongdn avatar weslleynasrocha 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.