Opt: Remove "+200Activity" and "Progress0/1" in daily quest OCR

This commit is contained in:
LmeSzinc 2023-09-20 13:34:29 +08:00
parent 07ef351ed7
commit ca2d7b4fb5
4 changed files with 28 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 226 KiB

View File

@ -210,13 +210,23 @@ DAILY_QUEST_RIGHT_END = ButtonWrapper(
button=(401, 259, 411, 632), 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( OCR_DAILY_QUEST = ButtonWrapper(
name='OCR_DAILY_QUEST', name='OCR_DAILY_QUEST',
share=Button( share=Button(
file='./assets/share/daily/reward/OCR_DAILY_QUEST.png', file='./assets/share/daily/reward/OCR_DAILY_QUEST.png',
area=(117, 257, 1173, 630), area=(117, 308, 1173, 630),
search=(97, 237, 1193, 650), search=(97, 288, 1193, 650),
color=(208, 206, 202), color=(204, 202, 199),
button=(117, 257, 1173, 630), button=(117, 308, 1173, 630),
), ),
) )

View File

@ -1,9 +1,12 @@
import cv2
import numpy as np import numpy as np
from module.base.timer import Timer 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.ocr import Ocr, OcrResultButton
from module.ocr.utils import split_and_pair_buttons 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.assets.assets_daily_reward import *
from tasks.daily.camera import CameraUI from tasks.daily.camera import CameraUI
from tasks.daily.keywords import ( 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.dungeon.ui import DungeonUI
from tasks.item.consumable_usage import ConsumableUsageUI from tasks.item.consumable_usage import ConsumableUsageUI
from tasks.item.relics import RelicsUI from tasks.item.relics import RelicsUI
from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST
class DailyQuestOcr(Ocr): class DailyQuestOcr(Ocr):
def __init__(self, button: ButtonWrapper, lang=None, name=None): merge_thres_y = 20
super().__init__(button, lang, name)
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): def after_process(self, result):
result = super().after_process(result) result = super().after_process(result)
@ -91,8 +100,7 @@ class DailyQuestUI(DungeonUI):
def _ocr_single_page(self) -> list[OcrResultButton]: def _ocr_single_page(self) -> list[OcrResultButton]:
ocr = DailyQuestOcr(OCR_DAILY_QUEST) ocr = DailyQuestOcr(OCR_DAILY_QUEST)
ocr.merge_thres_y = 20 results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest], direct_ocr=True)
results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest])
if len(results) < 8: if len(results) < 8:
logger.warning(f"Recognition failed at {8 - len(results)} quests on one page") logger.warning(f"Recognition failed at {8 - len(results)} quests on one page")