Skip to content

Commit

Permalink
选人界面识别改进
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Sep 30, 2023
1 parent c8b57e6 commit 0536b70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion arknights_mower/data/ocr.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@
"青积": "青枳",
"苍替": "苍苔",
"刻力": "刻刀",
"泰拉大陆调查": "泰拉大陆调查团"
"泰拉大陆调查": "泰拉大陆调查团",
"子": "",
"森": "森蚺"
}
19 changes: 14 additions & 5 deletions arknights_mower/utils/character_recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,30 @@ def sift_recog(query, resolution, draw=False,bigfont = False):

def paddle_recog(__img):
if len(res := arknights_mower.utils.paddleocr.ocr(__img)[1]) > 0:
logger.debug(f"PaddleOCR识别结果:{res}")
if op_name := next((r[0] for r in res if r[0] in agent_list), None):
return op_name
logger.debug(res)
for r in res:
if r[0] in agent_list:
op_name = r[0]
return op_name
if r[0] in ocr_error:
op_name = ocr_error[r[0]]
logger.debug(f"{r[0]} =====> {op_name}")
return op_name
recog_text = res[0][0]
best = None
best_score = 0
# “森蚺”可能识别成“森”,“孑”可能识别成“子”(子月)
# 以单字猜测双字干员不可靠
# 以“白面鹃”或“白面”匹配“白面鸮”没问题
for x in agent_sorted:
score = -abs(len(x) - len(recog_text))
for c in set(x):
score += 2 if c in recog_text else 0
if score > best_score:
best = x
best_score = score
if best_score > 0:
logger.debug(f"通过{recog_text}猜测干员:{best}")
if best_score > len(best):
logger.debug(f"{recog_text} --?--> {best}")
return best
return None

Expand Down

0 comments on commit 0536b70

Please sign in to comment.