From ceaef9c6a6f78e704c7810a37e76f8c386c1de55 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Mon, 9 Mar 2026 22:57:39 +0100 Subject: [PATCH] fix: Sub-Sessions original_bgr als cropped_bgr promoten Spalten-/Zeilen-/Woerter-Erkennung suchen nach cropped_bgr oder dewarped_bgr. Bei Sub-Sessions existiert nur original_bgr (der Box-Ausschnitt). Jetzt wird original_bgr automatisch als cropped_bgr gesetzt, sowohl im Cache-Aufbau als auch bei der Erstellung. Co-Authored-By: Claude Opus 4.6 --- klausur-service/backend/ocr_pipeline_api.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/klausur-service/backend/ocr_pipeline_api.py b/klausur-service/backend/ocr_pipeline_api.py index 70b3c2e..9f84987 100644 --- a/klausur-service/backend/ocr_pipeline_api.py +++ b/klausur-service/backend/ocr_pipeline_api.py @@ -127,6 +127,12 @@ async def _load_session_to_cache(session_id: str) -> Dict[str, Any]: bgr = cv2.imdecode(arr, cv2.IMREAD_COLOR) cache_entry[bgr_key] = bgr + # Sub-sessions: original image IS the cropped box region. + # Promote original_bgr to cropped_bgr so downstream steps find it. + if session.get("parent_session_id") and cache_entry["original_bgr"] is not None: + if cache_entry["cropped_bgr"] is None and cache_entry["dewarped_bgr"] is None: + cache_entry["cropped_bgr"] = cache_entry["original_bgr"] + _cache[session_id] = cache_entry return cache_entry @@ -465,13 +471,16 @@ async def create_box_sessions(session_id: str): ) # Cache the BGR for immediate processing + # Promote original to cropped so column/row/word detection finds it + box_bgr = crop.copy() _cache[sub_id] = { "id": sub_id, "filename": session.get("filename", "box-crop.png"), "name": sub_name, - "original_bgr": crop.copy(), + "parent_session_id": session_id, + "original_bgr": box_bgr, "oriented_bgr": None, - "cropped_bgr": None, + "cropped_bgr": box_bgr, "deskewed_bgr": None, "dewarped_bgr": None, "orientation_result": None,