15 lines
336 B
Python
15 lines
336 B
Python
"""OCR 引擎抽象接口。"""
|
|
from dataclasses import dataclass
|
|
from typing import Protocol
|
|
|
|
|
|
@dataclass
|
|
class OcrResult:
|
|
markdown: str
|
|
confidence: float # 0-1,未知时给 1.0
|
|
engine: str # "pix2text" / "vlm"
|
|
|
|
|
|
class OcrEngine(Protocol):
|
|
async def recognize(self, image_bytes: bytes, mime: str) -> OcrResult: ...
|