A powerful and efficient Android library that leverages the capabilities of OpenCV and MLKit to provide fast and precise document scanning functionality.
Please ⭐ this library if you found it useful and/or want to support its development.
- Fast and accurate document detection
- Perspective correction
- Image enhancement
- Cropping support
- Clone the repository using the following command:
git clone https://github.com/entropyconquers/android-document-scanner-library.git- Open the project in Android Studio and run the app module.
- Clone the repository using the following command:
git clone https://github.com/entropyconquers/android-document-scanner-library.git-
Open your project in Android Studio and select
File -> New -> Import Module -
Select the
scanLibmodule from the cloned repository and clickFinish -
Add the following lines to your app's
build.gradlefile:
dependencies {
implementation project(':scanLib')
}- Add mavencentral and jitpack repositories to your project's
build.gradle|settings.gradlefiles:
// build.gradle
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
}
// settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
}- Sync your project with gradle files
class MainActivity : BaseScannerActivity() {
override fun onError(throwable: Throwable) {
Log.d(ContentValues.TAG, "ERROR A")
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) {
}
override fun onClose() {
finish()
}
}The BaseScannerActivity class provides the following abstract methods that you need to implement:
abstract fun onError(throwable: Throwable) // Called when an error occurs
abstract fun onDocumentAccepted(bitmap: Bitmap) // Called when a document is accepted, returns the scanned bitmap
abstract fun onClose() // Called when the user presses the close buttonThis library has been built on top of the work of:
Kuama-IT, Android Document Scanner
MIT License