Skip to content

hannesa2/document-scanner

Repository files navigation

License: MIT example branch parameter

Android Document Scanner

Contains an activity that allows the user to scan a A4 paper with the smartphone camera. It is based on CameraX and OpenCV

Installation

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency

dependencies {
	implementation 'com.github.hannesa2:document-scanner:$version'
}

Usage

Inherit from BaseScannerActivity

class ScannerActivity : BaseScannerActivity() {
    override fun onError(throwable: Throwable) {
        when (throwable) {
            is NullCorners -> Toast.makeText(this, R.string.null_corners, Toast.LENGTH_LONG).show()
            else -> Toast.makeText(this, throwable.message, Toast.LENGTH_LONG).show()
        }
    }

    override fun onDocumentAccepted(bitmap: Bitmap) = Unit

    override fun onClose() {
        finish()
    }
}

Preview

Detect document

detect

Crop document

crop

About

Android document scanner

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •