From 87a7436b181ecc49825b95bdca2b6e98ffd7e11e Mon Sep 17 00:00:00 2001 From: Quildra Date: Tue, 29 Jul 2025 21:12:35 +0100 Subject: [PATCH] Expand OCR bounding boxes by 5% for ALL text classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove class-specific check and apply 5% expansion to all OCR detections - Improves text extraction accuracy across all Pokemon info fields - Stat values showed significant improvement, extending to all text classes - No overlap issues expected due to Pokemon Home UI spacing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../pokegoalshelper/ScreenCaptureService.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt b/app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt index 075f798..f37e6f7 100644 --- a/app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt +++ b/app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt @@ -636,22 +636,18 @@ class ScreenCaptureService : Service() { if (detection == null) return null try { - // Expand bounding box by 5% for stat value classes to improve OCR accuracy + // Expand bounding box by 5% for all OCR classes to improve text extraction accuracy val bbox = detection.boundingBox - val expandedBbox = if (detection.className in setOf("hp_value", "attack_value", "defense_value", "sp_atk_value", "sp_def_value", "speed_value")) { - val expansionFactor = 0.05f // 5% expansion - val widthExpansion = (bbox.width * expansionFactor).toInt() - val heightExpansion = (bbox.height * expansionFactor).toInt() - - Rect( - bbox.x - widthExpansion, - bbox.y - heightExpansion, - bbox.width + (2 * widthExpansion), - bbox.height + (2 * heightExpansion) - ) - } else { - bbox - } + val expansionFactor = 0.05f // 5% expansion + val widthExpansion = (bbox.width * expansionFactor).toInt() + val heightExpansion = (bbox.height * expansionFactor).toInt() + + val expandedBbox = Rect( + bbox.x - widthExpansion, + bbox.y - heightExpansion, + bbox.width + (2 * widthExpansion), + bbox.height + (2 * heightExpansion) + ) // Validate and clip bounding box to image boundaries val clippedX = kotlin.math.max(0, kotlin.math.min(expandedBbox.x, mat.cols() - 1))