mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-21 06:45:34 +08:00
Upd: resize and change similarity for 1920x1080 images in campaign
bonus
This commit is contained in:
@@ -15,12 +15,12 @@ class BonusItem(Item):
|
|||||||
class CampaignBonusStatistics(GetItemsStatistics):
|
class CampaignBonusStatistics(GetItemsStatistics):
|
||||||
bonus_button: Button = CAMPAIGN_BONUS
|
bonus_button: Button = CAMPAIGN_BONUS
|
||||||
|
|
||||||
def appear_on(self, image):
|
def appear_on(self, image, similarity=0.85):
|
||||||
if CAMPAIGN_BONUS_STRATEGY_CHECK.match(image, offset=(200, 500)):
|
if CAMPAIGN_BONUS_STRATEGY_CHECK.match(image, offset=(200, 500), similarity=similarity):
|
||||||
return False
|
return False
|
||||||
if AUTO_SEARCH_MENU_EXIT.match(image, offset=(200, 20)) \
|
if AUTO_SEARCH_MENU_EXIT.match(image, offset=(200, 20), similarity=similarity) \
|
||||||
and (CAMPAIGN_BONUS.match(image, offset=(200, 500)) \
|
and (CAMPAIGN_BONUS.match(image, offset=(200, 500), similarity=similarity) \
|
||||||
and CAMPAIGN_BONUS_SINGLE.match(image, offset=(200, 500))):
|
and CAMPAIGN_BONUS_SINGLE.match(image, offset=(200, 500), similarity=similarity)):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -82,11 +82,13 @@ class DropStatistics:
|
|||||||
Extract template from a single file.
|
Extract template from a single file.
|
||||||
New templates will be given an auto-increased ID.
|
New templates will be given an auto-increased ID.
|
||||||
"""
|
"""
|
||||||
images = unpack(load_image(file))[-1::]
|
image = load_image(file)
|
||||||
|
similarity = get_similarity(image)
|
||||||
|
images = unpack(image)[-1::]
|
||||||
for image in images:
|
for image in images:
|
||||||
# if self.get_items.appear_on(image):
|
# if self.get_items.appear_on(image):
|
||||||
# self.get_items.extract_template(image, folder=self.template_folder)
|
# self.get_items.extract_template(image, folder=self.template_folder)
|
||||||
if self.campaign_bonus.appear_on(image):
|
if self.campaign_bonus.appear_on(image, similarity=similarity):
|
||||||
for button in [CAMPAIGN_BONUS_SINGLE, CAMPAIGN_BONUS]:
|
for button in [CAMPAIGN_BONUS_SINGLE, CAMPAIGN_BONUS]:
|
||||||
self.campaign_bonus.bonus_button = button
|
self.campaign_bonus.bonus_button = button
|
||||||
self.campaign_bonus.extract_template(image, folder=self.template_folder)
|
self.campaign_bonus.extract_template(image, folder=self.template_folder)
|
||||||
@@ -105,7 +107,9 @@ class DropStatistics:
|
|||||||
"""
|
"""
|
||||||
ts = os.path.splitext(os.path.basename(file))[0]
|
ts = os.path.splitext(os.path.basename(file))[0]
|
||||||
campaign = os.path.basename(os.path.abspath(os.path.join(file, '../')))
|
campaign = os.path.basename(os.path.abspath(os.path.join(file, '../')))
|
||||||
images = unpack(load_image(file))[-1::]
|
image = load_image(file)
|
||||||
|
similarity = get_similarity(image)
|
||||||
|
images = unpack(image)[-1::]
|
||||||
enemy_name = 'unknown'
|
enemy_name = 'unknown'
|
||||||
for image in images:
|
for image in images:
|
||||||
# if self.battle_status.appear_on(image):
|
# if self.battle_status.appear_on(image):
|
||||||
@@ -113,7 +117,7 @@ class DropStatistics:
|
|||||||
# if self.get_items.appear_on(image):
|
# if self.get_items.appear_on(image):
|
||||||
# for item in self.get_items.stats_get_items(image):
|
# for item in self.get_items.stats_get_items(image):
|
||||||
# yield [ts, campaign, enemy_name, 'GET_ITEMS', item.name, item.amount]
|
# yield [ts, campaign, enemy_name, 'GET_ITEMS', item.name, item.amount]
|
||||||
if self.campaign_bonus.appear_on(image):
|
if self.campaign_bonus.appear_on(image, similarity=similarity):
|
||||||
for button in [CAMPAIGN_BONUS_SINGLE, CAMPAIGN_BONUS]:
|
for button in [CAMPAIGN_BONUS_SINGLE, CAMPAIGN_BONUS]:
|
||||||
self.campaign_bonus.bonus_button = button
|
self.campaign_bonus.bonus_button = button
|
||||||
for item in self.campaign_bonus.stats_get_items(image):
|
for item in self.campaign_bonus.stats_get_items(image):
|
||||||
|
|||||||
@@ -68,7 +68,29 @@ def unpack(image):
|
|||||||
size = image_size(image)
|
size = image_size(image)
|
||||||
if size == (1280, 720):
|
if size == (1280, 720):
|
||||||
return [image]
|
return [image]
|
||||||
|
elif size[0] / 1280 == size[1] / 720:
|
||||||
|
return [cv2.resize(image, (1280, 720), interpolation=cv2.INTER_LANCZOS4)]
|
||||||
else:
|
else:
|
||||||
if size[0] != 1280 or size[1] % 720 != 0:
|
if size[0] != 1280 or size[1] % 720 != 0:
|
||||||
raise ImageInvalidResolution(f'Unexpected image size: {size}')
|
raise ImageInvalidResolution(f'Unexpected image size: {size}')
|
||||||
return [crop(image, (0, n * 720, 1280, (n + 1) * 720)) for n in range(size[1] // 720)]
|
return [crop(image, (0, n * 720, 1280, (n + 1) * 720)) for n in range(size[1] // 720)]
|
||||||
|
|
||||||
|
def get_similarity(image):
|
||||||
|
"""
|
||||||
|
Get similarity to.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
image:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: 0-1. Similarity.
|
||||||
|
"""
|
||||||
|
size = image_size(image)
|
||||||
|
if size == (1280, 720):
|
||||||
|
return 0.85
|
||||||
|
elif size[0] / 1280 == size[1] / 720:
|
||||||
|
return 0.7
|
||||||
|
else:
|
||||||
|
if size[0] != 1280 or size[1] % 720 != 0:
|
||||||
|
raise ImageInvalidResolution(f'Unexpected image size: {size}')
|
||||||
|
return 0.85
|
||||||
|
|||||||
Reference in New Issue
Block a user