diff --git a/assets/share/daily/reward/MASK_DAILY_QUEST.png b/assets/share/daily/reward/MASK_DAILY_QUEST.png new file mode 100644 index 000000000..96e4350f3 Binary files /dev/null and b/assets/share/daily/reward/MASK_DAILY_QUEST.png differ diff --git a/assets/share/daily/reward/OCR_DAILY_QUEST.png b/assets/share/daily/reward/OCR_DAILY_QUEST.png index c6afe52b4..d23f8254c 100644 Binary files a/assets/share/daily/reward/OCR_DAILY_QUEST.png and b/assets/share/daily/reward/OCR_DAILY_QUEST.png differ diff --git a/tasks/daily/assets/assets_daily_reward.py b/tasks/daily/assets/assets_daily_reward.py index f20a49872..3af59b030 100644 --- a/tasks/daily/assets/assets_daily_reward.py +++ b/tasks/daily/assets/assets_daily_reward.py @@ -210,13 +210,23 @@ DAILY_QUEST_RIGHT_END = ButtonWrapper( button=(401, 259, 411, 632), ), ) +MASK_DAILY_QUEST = ButtonWrapper( + name='MASK_DAILY_QUEST', + share=Button( + file='./assets/share/daily/reward/MASK_DAILY_QUEST.png', + area=(117, 308, 1173, 630), + search=(97, 288, 1193, 650), + color=(208, 208, 208), + button=(117, 308, 1173, 630), + ), +) OCR_DAILY_QUEST = ButtonWrapper( name='OCR_DAILY_QUEST', share=Button( file='./assets/share/daily/reward/OCR_DAILY_QUEST.png', - area=(117, 257, 1173, 630), - search=(97, 237, 1193, 650), - color=(208, 206, 202), - button=(117, 257, 1173, 630), + area=(117, 308, 1173, 630), + search=(97, 288, 1193, 650), + color=(204, 202, 199), + button=(117, 308, 1173, 630), ), ) diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index 699fbfc9e..6fd20afec 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -1,9 +1,12 @@ +import cv2 import numpy as np from module.base.timer import Timer -from module.logger import * +from module.base.utils import crop +from module.logger import logger from module.ocr.ocr import Ocr, OcrResultButton from module.ocr.utils import split_and_pair_buttons +from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST from tasks.daily.assets.assets_daily_reward import * from tasks.daily.camera import CameraUI from tasks.daily.keywords import ( @@ -19,12 +22,18 @@ from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DungeonUI from tasks.item.consumable_usage import ConsumableUsageUI from tasks.item.relics import RelicsUI -from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST class DailyQuestOcr(Ocr): - def __init__(self, button: ButtonWrapper, lang=None, name=None): - super().__init__(button, lang, name) + merge_thres_y = 20 + + def pre_process(self, image): + image = super().pre_process(image) + image = crop(image, OCR_DAILY_QUEST.area) + mask = MASK_DAILY_QUEST.matched_button.image + # Remove "+200Activity" + cv2.bitwise_and(image, mask, dst=image) + return image def after_process(self, result): result = super().after_process(result) @@ -91,8 +100,7 @@ class DailyQuestUI(DungeonUI): def _ocr_single_page(self) -> list[OcrResultButton]: ocr = DailyQuestOcr(OCR_DAILY_QUEST) - ocr.merge_thres_y = 20 - results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest]) + results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest], direct_ocr=True) if len(results) < 8: logger.warning(f"Recognition failed at {8 - len(results)} quests on one page")