fix: image variable not defined

This commit is contained in:
liuyuanchuang
2026-02-09 22:23:52 +08:00
parent 8114abc27a
commit f64bf25f67

View File

@@ -683,6 +683,14 @@ class MineruOCRService(OCRServiceBase):
Dict with 'markdown', 'latex', 'mathml' keys.
"""
try:
# Decode image_bytes to numpy array for potential formula recognition
image_bytes.seek(0)
image_data = np.frombuffer(image_bytes.read(), dtype=np.uint8)
original_image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
# Reset image_bytes for API request
image_bytes.seek(0)
# Prepare multipart form data
files = {"files": ("image.png", image_bytes, "image/png")}
@@ -715,7 +723,7 @@ class MineruOCRService(OCRServiceBase):
markdown_content = result["results"]["image"].get("md_content", "")
if "![](images/" in markdown_content:
markdown_content = self._extract_and_recognize_formulas(markdown_content, image)
markdown_content = self._extract_and_recognize_formulas(markdown_content, original_image)
# Apply postprocessing to fix OCR errors
markdown_content = _postprocess_markdown(markdown_content)