Android document scanner library

Step By Step Guide To Build Document Scanner Android App.

Aug 13, 2020 · 4 min read

I have been working on a document scanner app in android and as I have successfully released my app today, I decided to publish this blog today. If you are looking for the step-by-step guide to create a scanner app, this story might be useful to you.

Here are some snapshots from my app:

You can find it on play store using the following link

Rapid Doc — Apps on Google Play

Rapid doc is a mobile document scanner to scan image and documents, scan paper, scan whiteboards. Rapid doc is a indian…

Image Scanning for mobile app can be implemented using the following ways:

1. Implementing from scratch using OpenCV

2. Implementing using Readily available open-source libraries.

In this tutorial, we a re going to use a readily available scan library. There are a bunch of them but we are going to use the following library

jhansireddy/AndroidScannerDemo

ScanLibrary is an android document scanning library built on top of OpenCV, using the app you will be able to select…

To use this library you need to integrate it with your android studio project. here are steps for integration.

2. Place it in your project directory as shown in the screenshot.

3. Open and adjust SDK version with your current project, include dependencies, change it to ‘implementation’.

4. Go to File->New->Import Module :scanlibrary

5. 1. open setting.gradle and add library manually:

include ‘:app’, ‘:scanlibrary’

6. Include scan library in your project using implementation project(‘:scanlibrary’)

7. Then, add some permission

That’s it for integration now you can start building your document scanner. Along with this tutorial you should also check out the official documentation from the repository.

Building a document scanner primarily consists of 3 steps:

Step 1: Start the Camera and capture image.

Step 2: Detect edges.

Step 3: Use the edges in the image to find the contour (outline) representing the piece of paper being scanned.

Step 4: Apply a perspective transform to obtain the top-down view of the document.

  1. Capture Image using camera intent

2. The result can be retrieved using onActivtyResult:

Here we get the bitmap object which can be used to display in an imageview as shown in the above example. If you want to save the image you can do it as follows:

Читайте также:  Как удалить эксплорер с андроида

That’s it. Very Easy Isn’t it? If you face issues feel free to ask in comments.

Don’t forget to check out my app on the play store and leave your valuable opinion.

Источник

This library helps to scan a document like CamScanner.

Category: Android / MiscellaneousWatchers: 16Star: 372Fork: 130Last update: Dec 5, 2021

Android Document Scanner Library

This library helps you to scan any document like CamScanner.

You need to implement openCV to run this library via import module on Android Studio. Use OpenCV library on this repository. Follow the lines below:

File → New → Import Module

Select » openCVLibrary « you’ve downloaded from this repository.

File → Project Structure → Select app under modules (this is your app module) → Go to dependencies tab

Click + button → Module dependency → Select openCVLibrary → Click ok → Click ok

Add line below to your top level build.gradle

Add lines below to your app level build.gradle

And Sync the gradle

To start ImageCrop process

Catch the cropped image

On above Android 9.0 there is magnifier to help user to see zoomed image to crop.

You can customize something in layout via ScannerConstants.

(NEW) Version 1.5 Feature — Custom Scanner Activity!

With 1.5 version you have a feature to create your own Document Scanner Activity. You still can use old customization via ScannerConstants or you can create a new scanner activity for your layout.

Place Scanner layout to your layout

Extend your activity from DocumentScannerActivity

And after setting your view call startCropping() method

If you have a trouble you can follow follow com.labters.documentscanner.ImageCropActivity for how to do that.

Remove RxJava dependency.

Thanks RX library to improve this project.

Thanks OpenCV for this awesome library. — https://opencv.org/ and

Inspiration from aashari . Thanks him for his source codes. — https://github.com/aashari/android-opencv-camera-scanner

While startActivityForResult run app will stopped

In Java. Code

I only use dependency not add module Is it right way?

Function invertColor not working

Hello, I have a problem with the function invertColor , when I invert the for gray scale and crop the imagem i cannot invertColor again and get the original color with the image already cropped.

Could you help me?

Can’t find DocumentScanActivity

Hi, I want to use this library for a Test project. I’m using version 1.5.1. Here my gradle dependencies:

Follow the tutorial. It says

but when I want to extends my Activity from DocumentScannerActivity (or DocumentScanActivity. I found in the library), Android Studio does not recognize it.

Please, help me. Thank you!

Edge detection not working sometimes.

I had implemented this library in one of my project with the help of library I want to detect the id prof cards every thing is working fine but the problem is when card was placed on multicoloured background the edges of the card are not getting exactly identified in the sense the polygon view which allows the user to crop is getting applied to full background. Please help me to solve this issue

Feature/binarization

Invert Color not working

Hello. there’s a problem with invert color function, when I convert for gray scale and then crop the image and the result showing colorful image (original image). Gray scale not applied at cropped image.

Читайте также:  Команда для снятия графического ключа с андроида

Android 11 crashed application

Needs to be updated with new scoped permission. Currently crashing with Android 11.

FATAL EXCEPTION: RxCachedThreadScheduler-1

Hi there trying to implement this library into our Android App but it keeps crashing when we try and open the ImageCropActivity.

Our Android App specs: compileSdkVersion 30 minSdkVersion 21 targetSdkVersion 30 multiDexEnabled true

Kotlin 1.3.50 BuildToolsVersion 29.x openCVLibrary3412 (Works since we use it for other features in the app)

The actual error message.

app size increased by 30 MB with this library

After adding this library, app size increased by 30 MB. Is there a way to reduce the app size ?

Источник

Android Document Scanner SDK for native applications

The Scanbot Android Document Scanner SDK can be easily integrated into your existing Android application within a few business days, turning a regular smartphone or tablet into a mobile document scanning device.

How to create a document scanner for Android

The Scanbot Android Document Scanner library can be integrated into your mobile application within one business day, using the ready-to-use UI which is customizable to the CI. Classical Components allow a full customization of the user experience. Available for package I and upwards. Compliance with the DSGVO, GDPR and CCPA guaranteed.

  • ML-based document detection
  • Ready-to-use UI
  • Cropping
  • Output as PDF, JPG, or TIFF

Source code for the Document Scanner on Android, example projects and dependencies can be found on GitHub in version 1.1.

Requirements

Mobile Platforms

  • Android 5.0 (API Level 21) and higher

Mobile Device

  • Rear-facing camera with autofocus
  • Supported CPUs and Architectures (ABIs): armeabi-v7, arm64-v8a, x86, x86_64

Works with

Free trial

Test-drive the Scanbot SDK in your mobile app or website 30 days for free.

Get started

Here you can find all resources that you need to integrate the Scanbot SDK into your Android app.

Get it on GitHub

Example projects

Get the example apps to check out the implementation and see how it works.

Ready to try it?

Talk to one of our solutions experts to discover how we can solve your mobile data capture requirements or simply integrate it into your own mobile app or website right now.

Источник

Android document scanner library

Document Scanner with tiny OpenCV

Document Scanner is an Android library (kotlin based) for scanning documents based on CameraX API and a tiny version of OpenCV.

  • tiny version of OpenCV 4.4.0:
    • armeabi-v7a: 3.1 MB (original: 10.1 MB)
    • arm64-v8a: 5.6 MB (original: 18.8 MB)
    • x86: 16.7 MB (original: 38.6 MB)
    • x86_64: 25.1 MB (original: 53.7 MB)
  • live detection (also detect rectangle with one bent angle)
  • auto scan and flash support
  • edit detected rectangle
  • configure size of results using Compressor

Document Scanner is supported on Android devices starting from SDK 21 (Lollipop)

in root project build.gradle:

in app build.gradle:

In your Application class:

Create an Activity (e.g. AppScanActivity) that extends ScanActivity

Document Scanner library will return image files using fun onSuccess(scannerResults: ScannerResults) . ScannerResults contains 3 files:

  • originalImageFile — image from camera (with Configuration declared in your Application class).
  • croppedImageFile — cropped/document image
  • transformedImageFile — croppedPhotoFile with grayscale filter or null if grayscale is not applied

All errors are returned to app using fun onError(error: DocumentScannerErrorModel)

ErrorMessage is an enum containing the following error types:

  • TAKE_IMAGE_FROM_GALLERY_ERROR
  • PHOTO_CAPTURE_FAILED
  • CAMERA_USE_CASE_BINDING_FAILED
  • DETECT_LARGEST_QUADRILATERAL_FAILED
  • INVALID_IMAGE
  • CAMERA_PERMISSION_REFUSED_WITHOUT_NEVER_ASK_AGAIN
  • CAMERA_PERMISSION_REFUSED_GO_TO_SETTINGS
  • STORAGE_PERMISSION_REFUSED_WITHOUT_NEVER_ASK_AGAIN
  • STORAGE_PERMISSION_REFUSED_GO_TO_SETTINGS
  • CROPPING_FAILED
Читайте также:  Подбор вайфай для андроид

Throwable can be null for some error messages like Permissions

Источник

Android Document Scanner Library | Top 5 Curated List

Up next
Android Button Animation Top 8 Styles you can apply in Android Studio
Share article
What’s in this blog? Hide

Android Document Scanner Library, a Top 5 curated list of libraries build by developers to help you build an Android Document Scanner Application.

Android Document Scanner Library

Scan Library (Java)

ScanLibrary is an Android Document Scanner Library built on top of OpenCV, using the app you will be able to select the exact edges and crop the document accordingly from the selected 4 edges and change the perspective transformation of the cropped image.

Android document scanner library

Implement in project

To implement this library in your Android Studio project, first add the ‘scanlibrary’ folder inside the root of your project directory.

Then add the following line of code to your build.gradle (app) dependencies:

Using the Library

In your activity or fragment when you want to give an option of document scanning to user then, first ass the following permissions to your AndroidManifest.xml file:

Start the scanlibrary ScanActivity, with this the app will go to library, below is the sample code snippet:

Note: preference can be one of OPEN_CAMERA or OPEN_MEDIA or left empty, based on the passed preference the scan library decides to open camera or media or open the scan home page.

Once the scanning is done, the application is returned from scan library to main app.

To retrieve the scanned image, add onActivityResult in your activity or fragment from where you have started startActivityForResult, below is the sample code snippet:

Scanner WIP (Kotlin)

Skanner is an Android Document Scanner Library written in Kotlin that uses OpenCV for Android to scan a document within a given image.

Implement in Project

To include Skanner into your app using gradle just add JitPack repository to your root build.gradle

and add the dependency to your app build.gradle

You can reduce considerably the APK of your application by taking advantage of Apk Splits function of the Android Gradle plugin. You just have to add these lines to your build.gradle file:

CV Scanner (Java)

An OpenCV based Android Document Scanner Library for Android to scan/crop ID documents or Passports.

Using the Library

The easiest way is to launch the DocumentScannerActivity

You’ll get the path of the scanned image in onActivityResult(int requestCode, int resultCode, Intent data)

You can use the DocumentScannerFragment too

Openalpr-android (Java)

OpenALPR Android Document Scanner Library is an open source Automatic License Plate Recognition library written in C++ with bindings in C#, Java, Node.js, and Python. This project ports this library to Android.

Implement in the project

irst, add the following to your app’s build.gradle file:

Them include the openalpr-android dependency:

Using the Library

Copy the OpenALPR configuration file to your android project assets directory /main/assets/runtime_data/openalpr.conf , open it and update the runtime_dir to your project directory (for instance, for the sample project the directory is: runtime_dir = /data/data/com.sandro.openalprsample/runtime_data ).

After that just follow the code example below.

rn-doc-scanner-android (React)

Installation

or delete node_modules folder

select React Native: first option

inside manifest tag

inside application tag

change compileSdkVersion xx to

run react-native run-android —deviceId xxxx

Источник

Оцените статью