fix: Windows OCR把多行合并成一行,修复引擎选择误选Windows\n\n根因:生产环境Windows OCR在某些机器/版本上将多条消息合并成一条长行\n(如20行→1行,421字符),导致长度保护逻辑误选Windows(win_len 421 > \neasy_len*1.3=333)。\n\nEasyOCR输出20行正确切分,但被长度保护否决。\n\n修复:新增「行数差异保护」——当EasyOCR行数>=Windows 3x时强制选EasyOCR,\n因为行数多=切分准确,行数少=Windows把多行合并成一条。\n\n场景1: win=1行421字32.5分, easy=20行256字31.0分 → 选easyocr(原选windows)\n场景2: win=1行100字45分, easy=15行300字50分 → 选easyocr(长度保护已触发)\n场景3: win=10行, easy=5行 → 选windows(正常,Windows行数多)\n场景4: win=60分, easy=30分 → 选windows(分数差异大不进保护)\n场景5: win=5行, easy=15行 → 选easyocr(3x触发)\n场景6: win=5行, easy=12行 → 选windows(<3x不触发)
This commit is contained in:
@@ -2519,6 +2519,15 @@ class MessageMonitor:
|
||||
f"[ocr] 长度保护: win行数{win_lines}>=1.5x easy行数{easy_lines},"
|
||||
f"分数差仅{score_diff:.1f},强制选windows"
|
||||
)
|
||||
# ⭐ 2026-08-19 新增:行数差异保护——Windows OCR 在特定机器/版本上将多行
|
||||
# 文本合并成一条长行(如 20 行→1 行,421字符),导致长度保护误选 Windows。
|
||||
# 当 EasyOCR 行数 >= Windows 3x 时,强制选 EasyOCR(行数多=切分准确)。
|
||||
elif easy_lines >= win_lines * 3 and win_lines >= 1:
|
||||
chosen = "easyocr"
|
||||
logger.debug(
|
||||
f"[ocr] 行数差异保护: easy行数{easy_lines}>=3x win行数{win_lines},"
|
||||
f"Windows把多行合并成一条,强制选easyocr"
|
||||
)
|
||||
|
||||
self._ocr_engine_wins[chosen] = self._ocr_engine_wins.get(chosen, 0) + 1
|
||||
total = sum(self._ocr_engine_wins.values())
|
||||
|
||||
Reference in New Issue
Block a user