Open
Conversation
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add functionality for prioritizing specific rectangles in OCR
特定の矩形を優先的にテキスト認識する機能の実装 (Implement Priority Rectangle OCR Feature)
Oct 12, 2025
Owner
|
@copilot |
- Remove PriorityRectFilter approach - Add PriorityRectUtility helper class - Update WindowsMediaOcr, TesseractOcr, and OneOcr to handle priority rects internally - When priority rects are specified, skip full-screen OCR and only recognize specified rectangles - Each OCR module now has RecognizePriorityRectsAsync, RecognizeFullScreenAsync, and RecognizeRegionAsync methods Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Contributor
Author
フィルター処理からOCRモジュール内実装に変更しました。 変更内容:
コミット: c7e... |
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Owner
|
@copilot |
- Crop from original bitmap first, then scale the cropped region - This ensures coordinates are properly transformed from scaled crop space to original bitmap space - Fixed for WindowsMediaOcr, TesseractOcr, and OneOcr - Removed double-scaling issue where ToTextRect was applied incorrectly Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Contributor
Author
スケール、回転、クロップのタイミングを修正しました。 修正内容:
コミット: (最新コミット) |
…ture # Conflicts: # WindowTranslator.Abstractions/Properties/Resources.resx
…carnival # Conflicts: # Plugins/WindowTranslator.Plugin.OneOcrPlugin/OneOcr.cs # Plugins/WindowTranslator.Plugin.TesseractOCRPlugin/TesseractOcr.cs # WindowTranslator.Abstractions/BitmapUtility.cs # WindowTranslator.Abstractions/Modules/IOcrModule.cs # WindowTranslator.Abstractions/Properties/Resources.de.resx # WindowTranslator.Abstractions/Properties/Resources.en.resx # WindowTranslator.Abstractions/Properties/Resources.ko.resx # WindowTranslator.Abstractions/Properties/Resources.resx # WindowTranslator.Abstractions/Properties/Resources.vi.resx # WindowTranslator.Abstractions/Properties/Resources.zh-CN.resx # WindowTranslator.Abstractions/Properties/Resources.zh-TW.resx # WindowTranslator.Abstractions/WindowTranslator.Abstractions.csproj # WindowTranslator/Modules/Ocr/WindowsMediaOcr.cs
- 全画面OCRと優先矩形OCRを併用し、重なった結果は優先矩形を優先する共通処理 PriorityRectRecognizer を追加して3つのOCRモジュールから利用するように統一 - 設定画面の優先矩形専用エディタ(追加/削除/上下移動/キーワード編集)を追加 - 矩形選択ウィンドウを対象ウィンドウのクライアント領域に重ねて表示するように変更 - 優先矩形の文字列リソースを全21言語へ展開し、未使用のキーを削除 - 座標計算のテストを追加し、機能に不要な仕様書ファイルを削除 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- 全体の認識結果を破棄する判定を、優先矩形の「領域」ではなく 優先矩形で実際に認識できた「文字」との重なりに変更。 優先矩形で何も認識できなかった場合に領域内のテキストが消えないようにする - 画像サイズを基準にした閾値が切り出し画像では小さくなり、 優先矩形内の文字が誤って除外される問題を修正。 認識処理に元の全体画像を渡し、全体画像を基準に閾値を計算するように変更 - 矩形選択ウィンドウの位置をキャプチャ画像と同じ範囲に合わせ、 タイトルバーのあるウィンドウで選択位置がずれる問題を修正 - 1ピクセル未満に潰れた優先矩形で切り出しに失敗して翻訳が停止する問題を修正 - 優先矩形の認識処理のテストを追加 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- 全体の認識では優先矩形の中と外の文字がひとつのブロックに結合されることがあり、 個々の文字を基準に判定すると重なり割合が閾値を下回って破棄されず、 優先矩形の結果と重複して表示されてしまうため、破棄の判定を矩形の領域基準に戻した。 文字を認識できなかった矩形は優先領域として扱わないことで、 その領域の全体の認識結果が消えないようにしている - 設定画面が対象ウィンドウに重なっていても選択範囲が見えるように、 矩形選択時に対象ウィンドウを前面に出すように変更 - 新規ファイルにUTF-8 BOMを付与(.editorconfigの設定に合わせる) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
優先矩形の境界をまたぐ文字は切り出し画像で途中で切れて認識できず、 全体の認識結果も優先矩形と重なるため破棄されて翻訳が出なくなる。 判定ロジックでは解決できないため、選択時の案内文で回避を促す。 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
WindowsMediaOcr・OneOcr・TesseractOcrには優先矩形(PriorityRectRecognizer) が統合されていたが、LLMOcr(ChatGPT API)とGoogleAIOcr(Gemini)には統合 されておらず、これらのプラグインを使用している場合は優先矩形の設定が完全 に無視されていた。 「指定した矩形外もオーバーレイ表示されている。全く動作していない」という 報告を受けて、以下の実機検証を実施: - PriorityRectRecognizerのマージ・重複除去ロジックを既存ユニットテストと 実OCR APIで再検証(問題なし) - 座標変換ロジック(RectangleSelectionWindowの相対座標変換、DPI Awareness)を実際にウィンドウをキャプチャして検証(誤差はごくわずかで 問題なし) - 実際にテキストを入力したウィンドウをキャプチャしてOCRを実行するE2E 検証を実施し、優先矩形の内外でテキストが仕様通り扱われることを確認 これらの検証により、コアロジックと座標変換はIssue #286の仕様(全体OCRを 維持しつつ、被った場合のみ優先矩形を優先する)通りに正しく動作している ことを確認した。一方で、IOcrModule実装を横断的に確認したところ、LLMOcr とGoogleAIOcrには優先矩形の統合自体が漏れていることが判明した。これらの プラグインを使用している場合、優先矩形を設定しても全体OCRの結果しか得ら れず「全く動作していない」ように見える実装漏れがあったため、既存のOneOcr ・TesseractOcrと同じパターンでPriorityRectRecognizerを統合した。 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
指定した矩形のみをテキスト認識する機能
Freeesia
requested changes
Aug 11, 2026
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Freeesia
marked this pull request as ready for review
August 11, 2026 10:39
Freeesia
reviewed
Aug 23, 2026
…cognition-rectangle-feature # Conflicts: # Directory.Packages.props
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.
概要
OCR対象範囲を矩形で登録し、矩形が1件以上ある場合は画像全体を認識せず、指定範囲内だけをOCRするようにします。
Fixes #286
挙動
主な変更
PriorityRectRecognizerに集約gong-wpf-dragdropを使い、複数範囲をドラッグ&ドロップで並べ替え可能に変更WindowTranslator.Properties.Resourcesから直接参照CustomResourceManagerにより英語へフォールバックすることを実行時テストで確認PriorityRectDescriptionリソースを全言語から削除確認内容
dotnet test WindowTranslator.Tests/WindowTranslator.Tests.csproj --no-build --no-restore --runtime win-x64