fix: EasyOCR行数保护不受分数差影响,防Windows OCR粘连误选
根因:行数差异保护原本在score_diff<10的分支内, 但用户截图场景:win=70.8(1行1495字符) vs easy=31.1(68行481字符), 分数差39.7>10 → 整个保护被跳过 → 选Windows → 所有消息粘在一起。 修复:把行数差异保护移到score_diff判断之外, 只要EasyOCR行数>=Windows 3x就无条件选EasyOCR。 行数差异本身就是质量信号(行数多=切分准确)。
This commit is contained in:
+12
-9
@@ -2519,15 +2519,18 @@ 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"
|
||||
)
|
||||
|
||||
# ⭐ 2026-08-19 新增:行数差异保护(不受分数差影响)
|
||||
# Windows OCR 在复杂群聊环境常把多行消息合并成一条长行(如68行→1行,1495字符)。
|
||||
# EasyOCR 切分准确但每行短 → CJK总数少 → 分数低 → 看似"输了"。
|
||||
# 但行数差异本身就是质量信号:行数多=切分准确,行数少=Windows合并了消息。
|
||||
# 当 EasyOCR 行数 >= Windows 3x 时,无条件选 EasyOCR(防分数差大的误判)。
|
||||
if easy_lines >= win_lines * 3 and win_lines >= 1:
|
||||
chosen = "easyocr"
|
||||
logger.debug(
|
||||
f"[ocr] 行数差异保护(无条件): easy行数{easy_lines}>=3x win行数{win_lines},"
|
||||
f"分数差{score_diff:.1f},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