FGA
FGA copied to clipboard
feat: tesseract improvements
Pull Request Type
- [ ] Chore
- [ ] Bugfix
- [X] Feature Implementation
- [ ] Documentation
- [ ] Other
Related issue
Description
- Make the Tesseract load once per service
- ensure tesseract proper closing of resources
- Implement SHA-256 validation to verify file integrity during asset copying, while streamlining the copying process.
Screenshots
Testing
Additional context
This pull request refactors the TesseractOcrService and its integration into the project, improving resource management, error handling, and modularity. The changes also update the dependency injection setup and ensure proper cleanup of OCR-related resources.
Dependency Injection Updates:
- Removed the binding of
TesseractOcrServiceasOcrServicefromScriptsModuleand added it toServiceModuleto scope it appropriately to services. (ScriptsModule.kt: [1] [2] [3];ServiceModule.kt: [4] [5]
TesseractOcrService Enhancements:
- Changed the scope of
TesseractOcrServicefromScriptScopetoServiceScopedand implemented theAutoCloseableinterface for better resource management. (TesseractOcrService.kt: app/src/main/java/io/github/fate_grand_automata/imaging/TesseractOcrService.ktL4-R22) - Added hash-based validation for Tesseract training data files to ensure data integrity and avoid unnecessary file overwrites. (
TesseractOcrService.kt: [1] [2] - Replaced
finalizewith an explicitclosemethod for predictable cleanup of the Tesseract API and improved logging usingTimber. (TesseractOcrService.kt: app/src/main/java/io/github/fate_grand_automata/imaging/TesseractOcrService.ktL71-R149)
Integration with ScriptRunnerServiceController:
- Injected
OcrServiceintoScriptRunnerServiceControllerand ensured it is properly closed during cleanup to release resources. (ScriptRunnerServiceController.kt: [1] [2] [3]
OcrService Interface Update:
- Added a
closemethod to theOcrServiceinterface to standardize resource cleanup across implementations. (OcrService.kt: libautomata/src/main/java/io/github/lib_automata/OcrService.ktR5-R13)
Build 176
Download the latest APK for testing here
[!NOTE] You need a GitHub account to download the APK.
This URL is valid as long as the artifact has not expired yet.
Forgot to ask, is this ready to merge?
currently not