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))