OCR识别方法 Args: img: 图片数据(bytes、str、pathlib.PurePath或PIL.Image) png_fix: 是否修复PNG透明背景问题 probability: 是否返回概率信息 color_filter_colors: 颜色过滤预设颜色列表,如 ['red', 'blue'] color_filter_custom_ranges: 自定义HSV颜色范围列表,如 [((0,50,50), (
(self, img: Union[bytes, str, pathlib.PurePath, Image.Image],
png_fix: bool = False, probability: bool = False,
color_filter_colors: Optional[List[str]] = None,
color_filter_custom_ranges: Optional[List[Tuple[Tuple[int, int, int], Tuple[int, int, int]]]] = None)
| 93 | self.slide_engine = SlideEngine() |
| 94 | |
| 95 | def classification(self, img: Union[bytes, str, pathlib.PurePath, Image.Image], |
| 96 | png_fix: bool = False, probability: bool = False, |
| 97 | color_filter_colors: Optional[List[str]] = None, |
| 98 | color_filter_custom_ranges: Optional[List[Tuple[Tuple[int, int, int], Tuple[int, int, int]]]] = None) -> Union[str, Dict[str, Any]]: |
| 99 | """ |
| 100 | OCR识别方法 |
| 101 | |
| 102 | Args: |
| 103 | img: 图片数据(bytes、str、pathlib.PurePath或PIL.Image) |
| 104 | png_fix: 是否修复PNG透明背景问题 |
| 105 | probability: 是否返回概率信息 |
| 106 | color_filter_colors: 颜色过滤预设颜色列表,如 ['red', 'blue'] |
| 107 | color_filter_custom_ranges: 自定义HSV颜色范围列表,如 [((0,50,50), (10,255,255))] |
| 108 | |
| 109 | Returns: |
| 110 | 识别结果文本或包含概率信息的字典 |
| 111 | |
| 112 | Raises: |
| 113 | DDDDOCRError: 当功能未启用或识别失败时 |
| 114 | """ |
| 115 | if self.det: |
| 116 | raise DDDDOCRError("当前识别类型为目标检测") |
| 117 | |
| 118 | if not self.ocr_engine: |
| 119 | raise DDDDOCRError("OCR功能未初始化") |
| 120 | |
| 121 | return self.ocr_engine.predict( |
| 122 | image=img, |
| 123 | png_fix=png_fix, |
| 124 | probability=probability, |
| 125 | color_filter_colors=color_filter_colors, |
| 126 | color_filter_custom_ranges=color_filter_custom_ranges |
| 127 | ) |
| 128 | |
| 129 | def detection(self, img: Union[bytes, str, pathlib.PurePath, Image.Image]) -> List[List[int]]: |
| 130 | """ |
no test coverage detected