mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 06:07:40 +08:00
Fix: Detection of combat loading
- Opt: Now use template matching instead of color_bar_percentage
This commit is contained in:
parent
2d17825c74
commit
ed2e92b703
BIN
assets/cn/template/TEMPLATE_COMBAT_LOADING.png
Normal file
BIN
assets/cn/template/TEMPLATE_COMBAT_LOADING.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/en/template/TEMPLATE_COMBAT_LOADING.png
Normal file
BIN
assets/en/template/TEMPLATE_COMBAT_LOADING.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/jp/template/TEMPLATE_COMBAT_LOADING.png
Normal file
BIN
assets/jp/template/TEMPLATE_COMBAT_LOADING.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -39,6 +39,19 @@ class Template:
|
||||
# print(self.file, sim)
|
||||
return sim > similarity
|
||||
|
||||
def match_result(self, image):
|
||||
"""
|
||||
Args:
|
||||
image:
|
||||
|
||||
Returns:
|
||||
bool: If matches.
|
||||
"""
|
||||
res = cv2.matchTemplate(np.array(image), self.image, cv2.TM_CCOEFF_NORMED)
|
||||
_, sim, _, point = cv2.minMaxLoc(res)
|
||||
# print(self.file, sim)
|
||||
return sim, point
|
||||
|
||||
def match_multi(self, image, similarity=0.85):
|
||||
"""
|
||||
Args:
|
||||
|
@ -1,7 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import color_bar_percentage
|
||||
from module.combat.assets import *
|
||||
from module.combat.combat_auto import CombatAuto
|
||||
from module.combat.combat_manual import CombatManual
|
||||
@ -12,6 +11,7 @@ from module.handler.enemy_searching import EnemySearchingHandler
|
||||
from module.logger import logger
|
||||
from module.map.assets import MAP_OFFENSIVE
|
||||
from module.retire.retirement import Retirement
|
||||
from module.template.assets import TEMPLATE_COMBAT_LOADING
|
||||
from module.ui.assets import BACK_ARROW
|
||||
|
||||
|
||||
@ -62,13 +62,13 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
left = color_bar_percentage(self.device.image, area=LOADING_BAR.area, prev_color=(99, 150, 255))
|
||||
right = color_bar_percentage(self.device.image, area=LOADING_BAR.area, prev_color=(225, 225, 225), reverse=True)
|
||||
if 0.15 < left < 0.95 and right > 0.15 and left + right <= 1.2:
|
||||
logger.attr('Loading', f'{int(left * 100)}%({int(right * 100)}%)')
|
||||
similarity, location = TEMPLATE_COMBAT_LOADING.match_result(self.device.image.crop((0, 620, 1280, 720)))
|
||||
if similarity > 0.85:
|
||||
loading = (location[0] + 38 - LOADING_BAR.area[0]) / (LOADING_BAR.area[2] - LOADING_BAR.area[0])
|
||||
logger.attr('Loading', f'{int(loading * 100)}%')
|
||||
return True
|
||||
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_combat_executing(self):
|
||||
"""
|
||||
|
@ -7,6 +7,7 @@ from module.base.template import Template
|
||||
TEMPLATE_AMBUSH_EVADE_FAILED = Template(file={'cn': './assets/cn/template/TEMPLATE_AMBUSH_EVADE_FAILED.png', 'en': './assets/en/template/TEMPLATE_AMBUSH_EVADE_FAILED.png', 'jp': './assets/jp/template/TEMPLATE_AMBUSH_EVADE_FAILED.png'})
|
||||
TEMPLATE_AMBUSH_EVADE_SUCCESS = Template(file={'cn': './assets/cn/template/TEMPLATE_AMBUSH_EVADE_SUCCESS.png', 'en': './assets/en/template/TEMPLATE_AMBUSH_EVADE_SUCCESS.png', 'jp': './assets/jp/template/TEMPLATE_AMBUSH_EVADE_SUCCESS.png'})
|
||||
TEMPLATE_CAUGHT_BY_SIREN = Template(file={'cn': './assets/cn/template/TEMPLATE_CAUGHT_BY_SIREN.png', 'en': './assets/en/template/TEMPLATE_CAUGHT_BY_SIREN.png', 'jp': './assets/jp/template/TEMPLATE_CAUGHT_BY_SIREN.png'})
|
||||
TEMPLATE_COMBAT_LOADING = Template(file={'cn': './assets/cn/template/TEMPLATE_COMBAT_LOADING.png', 'en': './assets/en/template/TEMPLATE_COMBAT_LOADING.png', 'jp': './assets/jp/template/TEMPLATE_COMBAT_LOADING.png'})
|
||||
TEMPLATE_ENEMY_BOSS = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_BOSS.png', 'en': './assets/en/template/TEMPLATE_ENEMY_BOSS.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_BOSS.png'})
|
||||
TEMPLATE_ENEMY_CARRIER = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_CARRIER.png', 'en': './assets/en/template/TEMPLATE_ENEMY_CARRIER.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_CARRIER.png'})
|
||||
TEMPLATE_ENEMY_L = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_L.png', 'en': './assets/en/template/TEMPLATE_ENEMY_L.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_L.png'})
|
||||
|
Loading…
Reference in New Issue
Block a user