Skip to content

shubhanshu24510/ScanKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 Document Scanner with ML Kit on Android

License API

Easily integrate Google's ML Kit Document Scanner API into your Android app. This project offers a clean implementation, usage guide, and customization options for a seamless document scanning experience.


✨ Preview


🧪 Example Results


🔍 Feature Overview

Feature Description
📦 SDK play-services-mlkit-document-scanner
📥 Download Size ~300KB
⚡ Initialization Slight delay on first use (models/UI are downloaded)
🔧 Customization Gallery import, page limits, scanner modes

🧰 Tech Stack & Requirements

  • Minimum SDK: 21+
  • Dependencies:
    • Google Maven repository required in build.gradle
    • Kotlin + AndroidX + ML Kit Scanner

📦Installation

Add the dependency for the ML Kit document scanner library to your module's app-level build.gradle file:

dependencies {
    // ...
    implementation 'com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1'
}

⚙️Configuration

Customize the document scanner options:

 val options = GmsDocumentScannerOptions.Builder()
    .setGalleryImportAllowed(false)
    .setPageLimit(2)
    .setResultFormats(RESULT_FORMAT_JPEG, RESULT_FORMAT_PDF)
    .setScannerMode(SCANNER_MODE_FULL)
    .build()

📸 Start Scanning

val scanner = GmsDocumentScanning.getClient(options)
val scannerLauncher = registerForActivityResult(StartIntentSenderForResult()) { result ->
    if (result.resultCode == RESULT_OK) {
        val result = GmsDocumentScanningResult.fromActivityResultIntent(result.data)
        result.getPages()?.let { pages ->
            for (page in pages) {
                val imageUri = pages.get(0).getImageUri()
            }
        }
        result.getPdf()?.let { pdf ->
            val pdfUri = pdf.getUri()
            val pageCount = pdf.getPageCount()
        }
    }
}

scanner.getStartScanIntent(activity)
    .addOnSuccessListener { intentSender ->
        scannerLauncher.launch(IntentSenderRequest.Builder(intentSender).build())
    }
    .addOnFailureListener { exception ->
        // Handle failure
    }

🧱 Architecture Overview

  • Clean MVVM architecture with unidirectional data flow.
  • Loosely coupled layers for easy testing and scalability.
  • UI communicates with ViewModel → ViewModel fetches data via Repository.

🧩 UI Layer

UI Layer

  • ViewModel + DataBinding
  • Uses Bindables for two-way data binding.
  • Configuration changes are gracefully handled.

🔄 Data Layer

Data Layer

  • Offline-first using Room
  • Repository pattern ensures single source of truth
  • Clean separation between local and external sources
  • Repositories handle business logic and act as single source of truth.
  • Offline-first design using local caching and potential future cloud integration.

📐 Architecture Diagram

Overall Architecture

More on modularization: Google Guide

✅ MAD Score

🧾 Conclusion

By integrating ML Kit's Document Scanner, your app gains a seamless, native scanning experience powered by Google Play services. With flexible configuration and minimal setup, you can deliver high-quality scanning to your users.


🤝 Support

If you like this project, please consider ⭐ starring the repo and following me for more cool Android projects!

☕ You can also support my work by buying me a coffee:

Buy Me A Coffee


👨‍💻 Follow @shubhanshu24510 for more cool projects Copyright 2025 Shubhanshu Singh

📄 License

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0

About

Using Google ML Kit to implement Document Scanner App , which features has to scan the blur document Content convent the Real Content.

Resources

Stars

Watchers

Forks

Contributors

Languages