How onemoregres/screentranslator works
Main components
• Module (src/capture): This module handles screen capture including selecting and editing the capture area.
• OCR Module (src/ocr): Responsible for converting captured images to text using Tesseract. It also manages worker processes (recognizerworker) for background OCR processing.
• Correction Module (src/correct): Contains components for text correction, such as the Hunspell-based corrector.
• Translation Module (src/translate): Manages the process of translating recognized text using various online translation services. The translators folder holds scripts that implement support for services like Google, Bing, DeepL, etc.
• Representation Module (src/represent): Deals with displaying the results (translated text) in the UI, managing result widgets and editors.
• Services & Utilities (src/service): Includes helper classes for common functionalities (e.g., application translation, global actions, updates, widget state, etc.), as well as system-specific integrations like auto-launch (runatsystemstart) and single application enforcement.
Relationships and interactions
• The Capture Module (in src/capture) collects the screen region and passes the image to the OCR Module.
• The OCR Module processes the image, extracts text, and sends it to the Correction Module if necessary.
• Corrected text is then fed into the Translation Module, which uses one or more configured online services to get the translated text.
• The translated text is then handled by the Representation Module and displayed to the user (either as a pop-up, integrated text field, or another UI component).
• Module has clear input and output dataflows (for example, data flows from capture → OCR → correction → translation → representation).
Architectural patterns and design principles
• Modular design: The directory structure clearly segments functionalities (capture, ocr, correct, translate, represent, service).
• Layered architecture: Data flows are processed sequentially through modules. This segmentation makes it easier to pinpoint where errors occur or where extensions should be added (e.g., adding another translator or a new correction strategy).
• Worker-based processing: Several modules, such as OCR and correction, use worker classes (evident from files like recognizerworker.cpp and correctorworker.cpp), indicating asynchronous or multi-threaded processing.
• Dependency on external libraries: Mark external libraries like Qt (for UI and application framework), Tesseract and Leptonica (for OCR), and Hunspell (for text correction).
Relevant technologies and frameworks
• Qt 5: Used for UI, system tray integration, and overall application management.
• Tesseract & Leptonica: Core dependencies for the OCR functionality.
• Hunspell: Used in the correction module.
• Various online translation services implemented as separate JavaScript translators.
• CI/CD scripts and external dependency management present in the “share/ci” and “external” directories.