From ea69239e067754fa256535009ca94f3e07a23921 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Thu, 12 Mar 2026 15:04:04 +0100 Subject: [PATCH] fix: word_boxes in words_first use absolute pixels (consistent with v2 grid) words_first was storing word_boxes in percent coordinates while cv_cell_grid.py uses absolute pixel coordinates. The overlay slide mechanism divides by imgW to get percentages, so percent-in-percent caused positions near zero. Now both grid builders use the same format. Co-Authored-By: Claude Opus 4.6 --- klausur-service/backend/cv_words_first.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/klausur-service/backend/cv_words_first.py b/klausur-service/backend/cv_words_first.py index e386139..f1ca0bc 100644 --- a/klausur-service/backend/cv_words_first.py +++ b/klausur-service/backend/cv_words_first.py @@ -181,15 +181,15 @@ def _build_cells( confs = [w.get('conf', 0) for w in cell_words if w.get('conf', 0) > 0] avg_conf = sum(confs) / len(confs) if confs else 0.0 - # Word boxes with percent coordinates + # Word boxes with absolute pixel coordinates (consistent with cv_cell_grid.py) word_boxes = [] for w in sorted(cell_words, key=lambda ww: (ww['top'], ww['left'])): word_boxes.append({ 'text': w.get('text', ''), - 'left': round(w['left'] / img_w * 100, 2) if img_w else 0, - 'top': round(w['top'] / img_h * 100, 2) if img_h else 0, - 'width': round(w['width'] / img_w * 100, 2) if img_w else 0, - 'height': round(w['height'] / img_h * 100, 2) if img_h else 0, + 'left': w['left'], + 'top': w['top'], + 'width': w['width'], + 'height': w['height'], 'conf': w.get('conf', 0), })