Scan Empire is a robust and modern Android application designed for paper document digitization, advanced optical character recognition (OCR), and multi-format file conversion to PDF. Developed in Kotlin using the declarative UI framework Jetpack Compose, it follows a strict MVVM architecture and clean code principles. The majority of processing is performed locally on the device, ensuring maximum privacy and security for user data.
⚙️ Core Features & System Architecture
1. Hybrid OCR System (Offline & Online)
The app offers flexibility through two text recognition modes:
Local OCR (Tesseract): Uses a customized TessBaseAPI (Tesseract4Android) for completely offline text recognition. The app downloads language models in real-time if they are not present. Google ML Kit is integrated for automatic language detection, and a confidence-score comparison algorithm is implemented for automatic script recognition (Cyrillic vs. Latin).
Cloud OCR (Google Cloud Vision): Used for complex layouts or low-quality documents. Integrated via a credit system, it enables advanced cloud-based recognition without degrading device performance.
2. Advanced Image Processing & OpenCV Integration
Before running OCR, the image undergoes an advanced filtering and geometric correction process:
Geometric Correction (Deskewing): OpenCV automatically straightens tilted documents and detects edges.
Visual Optimization: Shadows are removed, and adaptive binarization (Otsu thresholding) is applied to maximize contrast between text and background.
Memory Management: Due to large image sizes, the app uses shared Mat objects and carefully manages resources to prevent OutOfMemory (OOM) errors.
3. Smart PDF Reconstruction (PdfReconstructor)
Using the PDFBox-Android library, the application converts recognized text into searchable PDF documents:
Smart Spacing: The algorithm calculates the exact layout and spacing between words based on their coordinates from the image, preserving the original structure of the document.
Hybrid Overlay (Searchable PDF): Text is rendered as an invisible layer directly on top of the original image. The user visually sees the scanned document but can search, select, and copy text.
4. Conversions & File Manipulation
All conversions are performed locally to protect user privacy:
Local Converters: Converts DOCX, Excel, and TXT documents into PDF.
Document Merging: Combines multiple images or existing PDF files into a single PDF document.
5. Security, Storage, and Monetization
The application is designed as a sustainable commercial product:
Authentication: Secure login and account linking using Google Credential Manager.
Storage: Uses Android Storage Access Framework (SAF), allowing users to choose their preferred saving path on the device or SD card.
Monetization: Built-in Google Play Billing for purchasing credits or subscriptions in the Premium Shop. Free usage is supported by non-intrusive ads (AdManager).
📐 Technical Stack
Asynchronous Processing: Kotlin Coroutines and Flows for executing heavy processes (scanning, OCR, model downloading) in the background.
Dependency Injection: Hilt (Dagger) ensures clean separation of concerns, easier testing, and application extensibility.
💡 Summary
Scan Empire is a comprehensive mobile digitization ecosystem. By combining local OpenCV processing, hybrid OCR, and smart PDF reconstruction, it delivers professional scanning capabilities in a modern and optimized interface.