mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-17 05:15:25 +08:00
Refactor: statistics module
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
from module.base.decorator import cached_property
|
||||
from module.combat.assets import BATTLE_STATUS_S
|
||||
from module.ocr.ocr import Ocr
|
||||
from module.statistics.assets import ENEMY_NAME
|
||||
|
||||
ENEMY_NAME_OCR = Ocr(ENEMY_NAME, lang='cnocr', threshold=128)
|
||||
|
||||
|
||||
class BattleStatusStatistics:
|
||||
def appear_on(self, image):
|
||||
return BATTLE_STATUS_S.appear_on(image)
|
||||
|
||||
@cached_property
|
||||
def ocr_object(self):
|
||||
return Ocr(ENEMY_NAME, lang='cnocr', threshold=128, name='ENEMY_NAME')
|
||||
|
||||
def stats_battle_status(self, image):
|
||||
"""
|
||||
Args:
|
||||
@@ -13,7 +20,7 @@ class BattleStatusStatistics:
|
||||
Returns:
|
||||
str: Enemy name, such as '中型主力舰队'.
|
||||
"""
|
||||
result = ENEMY_NAME_OCR.ocr(image)
|
||||
result = self.ocr_object.ocr(image)
|
||||
# Delete wrong OCR result
|
||||
for letter in '-一个―~(':
|
||||
result = result.replace(letter, '')
|
||||
|
||||
Reference in New Issue
Block a user