From d7cdc1a370248426b3a19235bf44c58a4aa97b77 Mon Sep 17 00:00:00 2001 From: wuzekai <3025054974@qq.com> Date: Tue, 8 Jul 2025 05:22:40 +0000 Subject: [PATCH] Update ocr.py --- ocr.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ocr.py b/ocr.py index 3050384..d45fe64 100644 --- a/ocr.py +++ b/ocr.py @@ -52,4 +52,14 @@ def ocr_inference(): # 提取调试信息 debug_lines = result.stdout.splitlines() pattern = re.compile(r"\[.*\] ppocr DEBUG: (.*?), (\d+\.\d+)") - results = [] \ No newline at end of file + results = [] + + for line in debug_lines: + match = pattern.search(line) + if match: + text = match.group(1).strip() + confidence = float(match.group(2)) + results.append({"text": text, "confidence": confidence}) + + if not results: + return jsonify({"error": "No valid OCR debug output found"}), 500 \ No newline at end of file -- 2.22.0