diff --git a/ocr.py b/ocr.py index 30503843d0676a33580cac09708f392dd5d7d4a7..d45fe64dd48c178167147274707bdccf69e6b6e0 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