优化:调整代码格式,增强可读性
This commit is contained in:
1 parent
3b4293365d
commit
4903e50ff2
15 files changed
+1968
-539
No files matched your search
@@ -1531,15 +1531,19 @@ class underlying_operations:
|
||||
# 否则继续重试
|
||||
continue
|
||||
|
||||
def analyse_pic_word(self, picname, change_color=0, pic_path=None):
|
||||
def analyse_pic_word(
|
||||
self, picname, change_color=0, pic_path=None, return_confidence=False
|
||||
):
|
||||
"""对指定图片运行 OCR 并返回拼接后的文本结果。
|
||||
|
||||
参数:
|
||||
picname: 用于分类和调试的图片名(如"福袋内容")
|
||||
change_color: 颜色处理模式,0=保留彩色,1/2=二值化等
|
||||
pic_path: 可选的图片路径,未提供时通过 `_find_pic_path` 查找
|
||||
return_confidence: 是否返回置信度信息(默认False,保持向后兼容)
|
||||
返回:
|
||||
识别到的文本(字符串),识别失败返回空字符串
|
||||
如果return_confidence=False: 识别到的文本(字符串),识别失败返回空字符串
|
||||
如果return_confidence=True: (text, confidence_info) 元组,其中confidence_info是置信度信息字典
|
||||
"""
|
||||
if not pic_path:
|
||||
try:
|
||||
@@ -1905,7 +1909,10 @@ class underlying_operations:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return text
|
||||
if return_confidence:
|
||||
return text, ocr_confidence_info
|
||||
else:
|
||||
return text
|
||||
|
||||
def analyse_pic_digits(self, picname, change_color=1, pic_path=None):
|
||||
"""轻量数字OCR识别函数,专门用于识别数字(0-9)。
|
||||
|
||||
Reference in new issue
Block a user