Giter Site home page Giter Site logo

shubham0204 / simple_document_scanner_android Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 4.0 239.57 MB

A simple document scanner app for Android available in two options - API-based and on-device inference

License: Apache License 2.0

Kotlin 100.00%
android fastapi image-processing kotlin opencv

simple_document_scanner_android's Introduction

๐Ÿ“„ Simple Document Scanner in Android

Banner

Document Scanning App

The simplest document scanning app. It only contains the code necessary to provide the basic functionality of a document scanning app, and hence can be extended to meet your requirements.

The app can either use an API to crop documents or built-in OpenCV package for on-device document scanning.

Using the API-based app

See main branch

This app calls an API to get the coordinates of the corners of the document and also to binarize it. The image processing algorithm remains the same in both the options.

The API is developed with FastAPI in Python and uses OkHttp as a client to make requests. For more details on how to run the API server, see Document Scanning API.

There's no additional setup required to setup the Android project for this app. Clone the main branch and open the resulting directory in Android Studio.

Using the on-device document scanning app

See on_device_scanning_app branch

This app uses OpenCV 4.5.5 Android SDK to uses the same image processing algorithm as that in API-based app.

Motivation

There are a lot of document scanner apps for Android, some of which are open-source and provide better accuracy. The perks of using and extending this project are,

  • The core idea behind this project was simplicity. The source code is easy to understand even for beginners in Android and they can easily familiarize themselves with it.
  • The project utilizes the latest Android libraries for Kotlin like Coroutines, Room, Scoped Storage
  • It provides two options to deploy the document scanning service. The Android app on the main branch uses an API to crop the documents whereas the Android app on the on_device_scanning_app performs detection on-device and works without any networking.
  • You can learn how to use OpenCV in Kotlin and its setup by viewing the on_device_scanning_app branch.

Android/Kotlin libraries used in this project

Document Scanning API

๐Ÿ‘‰ Go to the api branch

The api branch contains the code for the API built using FastAPI in Python. First, install the required packages from requirements.txt in a Python virtual environment,

> python venv doc_scanning_env
> source doc_scanning_env/bin/activate
> ( doc_scanning_env ) pip install -r requirements.txt

Using the API locally

To run the FastAPI server locally, use

> uvicorn main:app 

in the source code directory where main.py is located. Make sure that,

  • The mobile device on which the app is running and the computer on which the server runs, are connected to the same network.
  • On Windows, make sure you turn-off the Firewall while testing the app.

Using the Streamlit app

Stream App

You can also perform document scanning with the Streamlit app, that let's you upload your image and outputs the boundaries of the document. To run the Streamlit app locally, use,

> streamlit run app.py

Building and running the Docker image

You can bundle the code in a Docker image and build it,

# Make sure you're in the source directory
> docker build --tag document_scanning_api .

simple_document_scanner_android's People

Contributors

shubham0204 avatar

Stargazers

 avatar Prianshu Parashar avatar Tudor Trenchea avatar  avatar

Watchers

James Cloos avatar  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.