Repository navigation
Improve OCR initialization and enhance UI element lookup reliability - #82
Merged
Merged
Conversation
Refactor UI element lookup to trust cached coordinates unless a forced search is requested, improving reliability when image recognition is inconsistent. If template matching fails, fall back to manual coordinates before prompting the user. Removes previous verification of cached coordinates and changes fallback order. #80
Improve OCR init: DLL checks, error handling, trick-only Only initialize OCR for trick training, not feed/scratch. Add native DLL presence checks and clearer error messages for missing or failed OCR initialization. Improves user guidance and robustness.
Pre-load leptonica and tesseract DLLs using NativeLibrary.TryLoad to ensure compatibility with single-file executables and avoid P/Invoke issues. Enhance error messages for missing or failed DLL loads, including guidance on installing the Visual C++ Redistributable. Adjust DLL existence checks to match dependency order. #78
Upgraded actions/checkout, actions/setup-dotnet, and actions/upload-artifact from v4 to v5 in dev-build.yml and release.yml to use the latest major versions and ensure continued support and improvements.
Added FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true to both dev-build.yml and release.yml to ensure JavaScript-based GitHub Actions use Node.js 24 during workflow execution.
Updated dev-build.yml and release.yml to use actions/upload-artifact@v7 instead of v5 for uploading build artifacts. No other workflow logic was modified.
Remove manual pre-loading of native DLLs and set TesseractEnviornment.CustomSearchPath to the executable directory for automatic resolution. Simplify VerifyNativeDlls to only check for file existence, eliminating redundant error handling and dependency checks. #78
Added extensive logging to the OCR initialization process in TextRecognition.cs. Logs now include file and directory existence checks, assembly location, and status of required native DLLs and trained data. Also logs success or failure of Tesseract engine initialization, including error details and stack trace, to aid in debugging setup issues. #78
Updated AssemblyInfo.cs, ToonTown Rewritten Bot.csproj, and GlobalSettings.cs to reflect new version 2.3.1. This includes assembly version, file version, application version, and version string updates.
primetime43
added a commit
that referenced
this pull request
Sep 29, 2026
Improve OCR initialization and enhance UI element lookup reliability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v2.3.1 - Bug Fixes
Bug Fixes
Fix intermittent "can't find Red Fishing Button" dialog (keeps saying cant find red fishing button #80): Cached UI element coordinates are now trusted
without re-verifying via template matching on every call. The recapture dialog now only appears when no cached or
manual fallback coordinates are available, restoring the silent fallback behavior from before v2.3.0.
Fix OCR initialization crash for single-file published executables (Unable to use Doodle training or Auto Golf #78): Doodle training and auto golf would
crash with "Exception has been thrown by the target of an invocation" because Tesseract's internal DLL resolver uses
Assembly.Location, which returns empty in single-file apps. Fixed by settingTesseractEnviornment.CustomSearchPathto the exe directory before engine initialization. Added diagnostic logging for OCR init success/failure.
Fix doodle training crash when OCR fails (Unable to use Doodle training or Auto Golf #78): Feed and scratch training no longer require OCR — it's only
initialized when a trick is selected. Users whose OCR fails can still use feed/scratch by setting trick to "None".
Performance
cached after first detection and reused on subsequent calls, eliminating redundant template matching each cycle.
CI/CD
checkout,setup-dotnet,upload-artifact) to latest versions and enabled Node.js 24 toresolve deprecation warnings.