Skip to content

Improve OCR initialization and enhance UI element lookup reliability - #82

Merged
primetime43 merged 9 commits into
mainfrom
develop
Mar 25, 2026
Merged

primetime43 merged 9 commits into
mainfrom
develop

Conversation

@primetime43

Copy link
Copy Markdown
Owner

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 setting TesseractEnviornment.CustomSearchPath
    to 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

  • Speed up doodle training (Speed up doodle training #77): UI element coordinates (SpeedChat button, Feed button, Scratch button) are
    cached after first detection and reused on subsequent calls, eliminating redundant template matching each cycle.

CI/CD

  • Updated GitHub Actions (checkout, setup-dotnet, upload-artifact) to latest versions and enabled Node.js 24 to
    resolve deprecation warnings.

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 primetime43 self-assigned this Mar 25, 2026
@primetime43
primetime43 merged commit fa1bf7b into main Mar 25, 2026
2 checks passed
primetime43 added a commit that referenced this pull request Sep 29, 2026
Improve OCR initialization and enhance UI element lookup reliability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant