How abdelhak2406/ocr_project works
Project Type and Purpose
• This is a standalone desktop OCR (Optical Character Recognition) application written in Python.
• It provides a GUI for users to load images, applies pre-processing (binarisation & filtering), and then runs OCR to extract text.
File-Structure Analysis
• Top-level:
• src/main.py – application entry point (initializes GUI and application logic)
• requirements.txt – Python dependencies (likely including PyQt5, Pillow/OpenCV, pytesseract)
• src/app: core image-processing modules
• binarisation.py – converts image to binary (thresholding)
• filtrage.py – applies filtering (noise removal, smoothing)
• src/gui: GUI definition
• main_ocr.ui – Qt Designer XML layout
• main_ocr_ui.py – generated Python UI class
• No backend server or database – it’s a single-process desktop app.
Key Components
a. User Interface (UI) Layer
– Component: “GUI” (Qt)
– Sources: main_ocr.ui, main_ocr_ui.py, triggered by src/main.py
b. Application Core Layer
– Components:
• Image Loader (file I/O)
• Binarisation Module (src/app/binarisation.py)
• Filtering Module (src/app/filtrage.py)
• OCR Engine (external, e.g., pytesseract or Tesseract CLI)
– The core modules form a pipeline: Loader → Binarisation → Filtering → OCR
c. External Dependencies
– Tesseract OCR (or other engine)
– Python Libraries (PyQt5, Pillow/OpenCV)
d. Environment & Packaging
– Conda/Venv environment (requirements.txt)
– Entry point: src/main.py
Relationships & Data Flows
• User triggers “Open Image” in GUI →
GUI calls Image Loader →
Loaded image object passed to Binarisation →
Binarised image passed to Filtering →
Filtered image passed to OCR Engine →
OCR Engine returns text →
GUI displays recognized text.
• Configuration/Dependencies flow (side-channel): requirements.txt → environment → application runtime.
Architectural Patterns & Design Principles
• Separation of concerns: UI layer versus processing layer.
• Pipeline pattern for image processing.
• Modular design: each processing step is in its own module.
• Single‐process, synchronous flow (no microservices).
3. Below it, arrange the pipeline: File I/O → Binarisation → Filtering → OCR Engine.
4. At the far right, place “OCR Engine (pytesseract/Tesseract)”.
5. GUI to File I/O and then chain the pipeline.