End-to-end intelligent OCR system built with OpenCV, Tesseract, spaCy, and scikit-learn. Features robust photo preprocessing, named entity recognition, and mathematical text summarization without relying on GPU acceleration or external APIs.
Computer Vision: OpenCV, Tesseract OCR
NLP: spaCy, scikit-learn
Frontend: Streamlit
Core: Python, NumPy, Pillow
- Smart Document Detection: Automatically detects document boundaries and applies perspective transform to deskew the document.
- Image Enhancement Pipeline: Handles grayscale conversion, denoising, adaptive thresholding, and morphological operations to clean up noisy images.
- Lighting / Shadow Correction: Compensates for uneven lighting conditions often found in mobile scans.
- Layout Analysis: Segments headings, paragraphs, and tables using layout detection algorithms.
- Multi-language OCR: Extracts text in multiple languages via Tesseract OCR with customizable page segmentation modes.
- Confidence Visualization: Displays a per-word confidence overlay using a traffic-light color system (Green/Yellow/Red).
- Export Options: Download extracted text as plain
TXT, structuredJSON, or searchablePDF. - Batch Processing: Process multiple images at once and download a summary report.
Before running the app, you need to install Tesseract OCR on your system:
- macOS (using Homebrew):
brew install tesseract brew install tesseract-lang
- Ubuntu / Debian:
sudo apt install tesseract-ocr sudo apt install tesseract-ocr-all
- Windows:
Download the installer from UB-Mannheim/tesseract and install. Add the installation path to your system's
PATH.
- Clone or Download the Repository
- Create a Virtual Environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install Dependencies:
pip install -r requirements.txt
Run the Streamlit application:
streamlit run main.pyThe app will open automatically in your browser (usually at http://localhost:8501).
The sidebar provides various configuration options:
- Preprocessing: Toggle automatic document detection, lighting correction, and morphological cleanup.
- OCR Settings: Select the target language and Tesseract Page Segmentation Mode (PSM).
- Display Options: Toggle intermediate step visualizations like the layout regions and word-level confidence maps.
- Mode: Switch between "Single Image" and "Batch Processing".
intelligent-ocr-digitalization/
├── main.py # Streamlit web application entry point
├── src/
│ ├── ocr_engine.py # Core OCR processing pipeline
│ ├── preprocessing.py # Image enhancement and document detection
│ ├── layout_analysis.py # Region segmentation (headings, paragraphs, tables)
│ ├── exporters.py # TXT/JSON/PDF export handlers
│ └── utils.py # Helper functions and visualization
├── requirements.txt # Python dependencies
└── README.md
- Document Digitization: Convert physical receipts, contracts, and forms into searchable text
- Batch Processing: Process large volumes of scanned documents automatically
- Multi-language Support: Extract text from documents in various languages
- Quality Assessment: Confidence scoring helps identify text regions that need manual review
- Accessible Archives: Generate searchable PDFs from image-based documents
- Add deep learning-based text detection (EAST/CRAFT)
- Integrate table structure recognition
- Support handwriting recognition
- Add document classification pipeline
- Export to structured formats (CSV for tables)
Coming soon: Dashboard UI, confidence visualization, and before/after processing examples
Contributions are welcome! Feel free to open issues or submit pull requests.
MIT License - feel free to use this project for learning or commercial purposes.