From 36cfeffe9c0c11f08251c84a9e053335efda1b95 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Mon, 19 May 2025 20:35:11 +0200 Subject: [PATCH] fix: correct center-point calculation in OCR results --- ai/compute.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ai/compute.py b/ai/compute.py index 11de32e..2acd277 100644 --- a/ai/compute.py +++ b/ai/compute.py @@ -45,10 +45,11 @@ def perform_ocr(screenshot: bytes) -> list[dict]: for i in range(n): text = data['text'][i] if text and text.strip(): + # Fix the center-point calculation (add first, then divide) results.append({ 'text': text, - 'x': data['width'][i] + data['left'][i] // 2, # center x position - 'y': data['height'][i] + data['top'][i] // 2 # center y position + 'x': data['left'][i] + data['width'][i] // 2, + 'y': data['top'][i] + data['height'][i] // 2 }) # check if debug is enabled