2025-06-10 17:34:52 -04:00
|
|
|
from typing import Iterable
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
import numpy.typing as npt
|
|
|
|
|
from rapidocr.utils.typings import EngineType
|
|
|
|
|
from typing_extensions import TypedDict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TextDetectionOutput(TypedDict):
|
2025-06-16 16:24:26 -04:00
|
|
|
image: npt.NDArray[np.float32]
|
2025-06-10 17:34:52 -04:00
|
|
|
boxes: npt.NDArray[np.float32]
|
2025-06-13 00:39:39 -04:00
|
|
|
scores: npt.NDArray[np.float32]
|
2025-06-10 17:34:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TextRecognitionOutput(TypedDict):
|
|
|
|
|
box: npt.NDArray[np.float32]
|
2025-06-16 16:24:26 -04:00
|
|
|
boxScore: npt.NDArray[np.float32]
|
2025-06-10 17:34:52 -04:00
|
|
|
text: Iterable[str]
|
2025-06-16 16:24:26 -04:00
|
|
|
textScore: npt.NDArray[np.float32]
|
2025-06-10 17:34:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# RapidOCR expects engine_type to be an attribute
|
|
|
|
|
class OcrOptions(dict):
|
|
|
|
|
def __init__(self, **options):
|
|
|
|
|
super().__init__(**options)
|
|
|
|
|
self.engine_type = EngineType.ONNXRUNTIME
|