How glcrealm/optical-character-recognition works
Main Components
a. User Interface (UI)
• Script: compleat.py
• Built on Python with customtkinter
b. OCR Core / Application Logic
• Preprocessing & helper functions: firstuse.py
• Segmentation & Tesseract integration: ocr6.py
c. Machine Learning Model
• Serialized neural network: first_model.pkl (TensorFlow/Keras)
d. External Engine
• Tesseract OCR binary (external dependency invoked by pytesseract)
e. Data Sources
• Input images (via GUI “Import”)
• Test dataset folder (for validation)
f. Supporting Libraries & Environment
• Python 3.x, numpy, Pillow, customtkinter, pytesseract, tensorflow, pickle
Relationships & Data Flows
1. User Action → GUI layer (compleat.py) receives image file.
2. Image Preprocessing → GUI calls functions in firstuse.py (thresholding, resizing).
4. Tesseract OCR → For baseline extraction or to handle whitespace/line breaks, pytesseract calls Tesseract binary.
5. Deep Learning Prediction → Each segmented character tile fed into first_model.pkl via TensorFlow API.
6. Aggregation → Recognized characters are concatenated into strings.
8. Optional → Test dataset can be piped through the same pipeline for batch evaluation.
Architectural Patterns & Design Principles
• Modular Separation: UI separated from OCR logic and ML model.
• Pipeline Pattern: Sequential stages (preprocessing → segmentation → prediction → display).
• Dependency Injection: External Tesseract path is configurable in ocr6.py.
Additional Details to Capture
• Configuration point: Tesseract path in ocr6.py.
• ML framework: TensorFlow (version if known).