mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:07:36 +08:00
Refactor: info_bar_count() for poor image quality
This commit is contained in:
parent
0bcad85825
commit
ffbac284dd
BIN
assets/cn/handler/INFO_BAR_AREA.png
Normal file
BIN
assets/cn/handler/INFO_BAR_AREA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
BIN
assets/en/handler/INFO_BAR_AREA.png
Normal file
BIN
assets/en/handler/INFO_BAR_AREA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
BIN
assets/jp/handler/INFO_BAR_AREA.png
Normal file
BIN
assets/jp/handler/INFO_BAR_AREA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
BIN
assets/tw/handler/INFO_BAR_AREA.png
Normal file
BIN
assets/tw/handler/INFO_BAR_AREA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
@ -53,7 +53,11 @@ class AmbushHandler(Combat):
|
||||
logger.info('Map ambushed')
|
||||
self.wait_until_appear_then_click(MAP_AMBUSH_EVADE)
|
||||
|
||||
self.wait_until_appear(INFO_BAR_1)
|
||||
# self.wait_until_appear(INFO_BAR_1)
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
if self.info_bar_count():
|
||||
break
|
||||
image = info_letter_preprocess(self.image_crop(INFO_BAR_DETECT))
|
||||
|
||||
if TEMPLATE_AMBUSH_EVADE_SUCCESS.match(image):
|
||||
@ -114,7 +118,7 @@ class AmbushHandler(Combat):
|
||||
def handle_walk_out_of_step(self):
|
||||
if not self.config.MAP_HAS_FLEET_STEP:
|
||||
return False
|
||||
if not self.appear(INFO_BAR_1):
|
||||
if not self.info_bar_count():
|
||||
return False
|
||||
|
||||
image = info_letter_preprocess(self.image_crop(INFO_BAR_DETECT))
|
||||
|
@ -38,6 +38,7 @@ GUILD_POPUP_CONFIRM = Button(area={'cn': (655, 450, 856, 487), 'en': (658, 453,
|
||||
INFO_BAR_1 = Button(area={'cn': (202, 297, 1078, 299), 'en': (194, 297, 1086, 299), 'jp': (194, 297, 1086, 299), 'tw': (200, 297, 1080, 299)}, color={'cn': (107, 158, 255), 'en': (107, 158, 255), 'jp': (107, 158, 255), 'tw': (107, 158, 255)}, button={'cn': (202, 297, 1078, 299), 'en': (194, 297, 1086, 299), 'jp': (194, 297, 1086, 299), 'tw': (200, 297, 1080, 299)}, file={'cn': './assets/cn/handler/INFO_BAR_1.png', 'en': './assets/en/handler/INFO_BAR_1.png', 'jp': './assets/jp/handler/INFO_BAR_1.png', 'tw': './assets/tw/handler/INFO_BAR_1.png'})
|
||||
INFO_BAR_2 = Button(area={'cn': (202, 241, 1078, 243), 'en': (194, 241, 1086, 243), 'jp': (194, 234, 1086, 236), 'tw': (200, 241, 1080, 243)}, color={'cn': (107, 158, 255), 'en': (107, 158, 255), 'jp': (107, 158, 255), 'tw': (107, 158, 255)}, button={'cn': (202, 241, 1078, 243), 'en': (194, 241, 1086, 243), 'jp': (194, 234, 1086, 236), 'tw': (200, 241, 1080, 243)}, file={'cn': './assets/cn/handler/INFO_BAR_2.png', 'en': './assets/en/handler/INFO_BAR_2.png', 'jp': './assets/jp/handler/INFO_BAR_2.png', 'tw': './assets/tw/handler/INFO_BAR_2.png'})
|
||||
INFO_BAR_3 = Button(area={'cn': (202, 185, 1078, 187), 'en': (194, 185, 1086, 187), 'jp': (194, 171, 1086, 173), 'tw': (200, 185, 1080, 187)}, color={'cn': (107, 158, 255), 'en': (107, 158, 255), 'jp': (107, 158, 255), 'tw': (107, 158, 255)}, button={'cn': (202, 185, 1078, 187), 'en': (194, 185, 1086, 187), 'jp': (194, 171, 1086, 173), 'tw': (200, 185, 1080, 187)}, file={'cn': './assets/cn/handler/INFO_BAR_3.png', 'en': './assets/en/handler/INFO_BAR_3.png', 'jp': './assets/jp/handler/INFO_BAR_3.png', 'tw': './assets/tw/handler/INFO_BAR_3.png'})
|
||||
INFO_BAR_AREA = Button(area={'cn': (200, 173, 1080, 348), 'en': (200, 173, 1080, 348), 'jp': (200, 173, 1080, 348), 'tw': (200, 173, 1080, 348)}, color={'cn': (71, 85, 102), 'en': (71, 85, 102), 'jp': (71, 85, 102), 'tw': (71, 85, 102)}, button={'cn': (200, 173, 1080, 348), 'en': (200, 173, 1080, 348), 'jp': (200, 173, 1080, 348), 'tw': (200, 173, 1080, 348)}, file={'cn': './assets/cn/handler/INFO_BAR_AREA.png', 'en': './assets/en/handler/INFO_BAR_AREA.png', 'jp': './assets/jp/handler/INFO_BAR_AREA.png', 'tw': './assets/tw/handler/INFO_BAR_AREA.png'})
|
||||
INFO_BAR_DETECT = Button(area={'cn': (194, 299, 1086, 348), 'en': (194, 299, 1086, 348), 'jp': (194, 299, 1086, 348), 'tw': (194, 299, 1086, 348)}, color={'cn': (48, 53, 65), 'en': (48, 53, 65), 'jp': (48, 53, 65), 'tw': (48, 53, 65)}, button={'cn': (194, 299, 1086, 348), 'en': (194, 299, 1086, 348), 'jp': (194, 299, 1086, 348), 'tw': (194, 299, 1086, 348)}, file={'cn': './assets/cn/handler/INFO_BAR_DETECT.png', 'en': './assets/en/handler/INFO_BAR_DETECT.png', 'jp': './assets/jp/handler/INFO_BAR_DETECT.png', 'tw': './assets/tw/handler/INFO_BAR_DETECT.png'})
|
||||
IN_MAP = Button(area={'cn': (749, 654, 921, 707), 'en': (757, 654, 917, 699), 'jp': (748, 653, 919, 705), 'tw': (749, 654, 921, 707)}, color={'cn': (213, 124, 124), 'en': (215, 132, 132), 'jp': (212, 124, 124), 'tw': (213, 124, 124)}, button={'cn': (749, 654, 921, 707), 'en': (757, 654, 917, 699), 'jp': (748, 653, 919, 705), 'tw': (749, 654, 921, 707)}, file={'cn': './assets/cn/handler/IN_MAP.png', 'en': './assets/en/handler/IN_MAP.png', 'jp': './assets/jp/handler/IN_MAP.png', 'tw': './assets/tw/handler/IN_MAP.png'})
|
||||
IN_STAGE = Button(area={'cn': (122, 16, 172, 39), 'en': (120, 18, 208, 40), 'jp': (121, 15, 174, 40), 'tw': (122, 16, 172, 39)}, color={'cn': (149, 167, 207), 'en': (104, 118, 157), 'jp': (151, 167, 205), 'tw': (149, 167, 207)}, button={'cn': (122, 16, 172, 39), 'en': (120, 18, 208, 40), 'jp': (121, 15, 174, 40), 'tw': (122, 16, 172, 39)}, file={'cn': './assets/cn/handler/IN_STAGE.png', 'en': './assets/en/handler/IN_STAGE.png', 'jp': './assets/jp/handler/IN_STAGE.png', 'tw': './assets/tw/handler/IN_STAGE.png'})
|
||||
|
@ -34,18 +34,35 @@ class InfoHandler(ModuleBase):
|
||||
"""
|
||||
|
||||
def info_bar_count(self):
|
||||
if self.appear(INFO_BAR_3):
|
||||
return 3
|
||||
elif self.appear(INFO_BAR_2):
|
||||
return 2
|
||||
elif self.appear(INFO_BAR_1):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
"""
|
||||
Detect info bar by the blue lines on the top of it.
|
||||
|
||||
Returns:
|
||||
int:
|
||||
"""
|
||||
image = self.image_crop(INFO_BAR_AREA)
|
||||
line = cv2.resize(image, (1, image.shape[0]), interpolation=cv2.INTER_LINEAR)
|
||||
line = color_similarity_2d(line, color=(107, 158, 255))[:, 0]
|
||||
|
||||
parameters = {
|
||||
'height': 235,
|
||||
'prominence': 50,
|
||||
'width': (0, 4),
|
||||
# Blue lines are in a interval of 56
|
||||
'distance': 50,
|
||||
}
|
||||
peaks, _ = signal.find_peaks(line, **parameters)
|
||||
return len(peaks)
|
||||
|
||||
def wait_until_info_bar_disappear(self):
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
if not self.info_bar_count():
|
||||
break
|
||||
|
||||
def handle_info_bar(self):
|
||||
if self.info_bar_count():
|
||||
self.wait_until_disappear(INFO_BAR_1)
|
||||
self.wait_until_info_bar_disappear()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -2,7 +2,6 @@ from copy import deepcopy
|
||||
|
||||
from module.base.button import ButtonGrid
|
||||
from module.base.timer import Timer
|
||||
from module.handler.assets import INFO_BAR_1
|
||||
from module.logger import logger
|
||||
from module.meowfficer.assets import *
|
||||
from module.meowfficer.collect import MeowfficerCollect
|
||||
@ -81,7 +80,7 @@ class MeowfficerTrain(MeowfficerCollect, MeowfficerEnhance):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(INFO_BAR_1):
|
||||
if self.info_bar_count():
|
||||
confirm_timer.reset()
|
||||
continue
|
||||
if self.appear_then_click(MEOWFFICER_TRAIN_FILL_QUEUE, offset=(20, 20), interval=5):
|
||||
|
Loading…
Reference in New Issue
Block a user