Browse Source

Expand OCR bounding boxes by 5% for ALL text classes

- 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 <noreply@anthropic.com>
feature/expand-stat-ocr-boxes
Quildra 5 months ago
parent
commit
87a7436b18
  1. 26
      app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt

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

Loading…
Cancel
Save