mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Handle OCR_WORLD moving up and down
This commit is contained in:
parent
5191674920
commit
1d5692fa45
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 31 KiB |
@ -27,10 +27,10 @@ OCR_WORLD = ButtonWrapper(
|
|||||||
name='OCR_WORLD',
|
name='OCR_WORLD',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/rogue/entry/OCR_WORLD.png',
|
file='./assets/share/rogue/entry/OCR_WORLD.png',
|
||||||
area=(488, 339, 718, 371),
|
area=(488, 339, 718, 395),
|
||||||
search=(468, 319, 738, 391),
|
search=(468, 319, 738, 415),
|
||||||
color=(45, 44, 68),
|
color=(38, 35, 64),
|
||||||
button=(488, 339, 718, 371),
|
button=(488, 339, 718, 395),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
THEME_DLC = ButtonWrapper(
|
THEME_DLC = ButtonWrapper(
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
|
from module.base.utils import color_similarity_2d
|
||||||
from module.exception import RequestHumanTakeover, ScriptError
|
from module.exception import RequestHumanTakeover, ScriptError
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr
|
from module.ocr.ocr import Ocr
|
||||||
@ -67,6 +71,16 @@ def chinese_to_arabic(chinese_number: str) -> int:
|
|||||||
|
|
||||||
|
|
||||||
class OcrRogueWorld(Ocr):
|
class OcrRogueWorld(Ocr):
|
||||||
|
def pre_process(self, image):
|
||||||
|
# Letter randomly moving up and down
|
||||||
|
# Crop to the up/down border of the white letter
|
||||||
|
center = color_similarity_2d(image, color=(255, 255, 255))
|
||||||
|
cv2.inRange(center, 180, 255, dst=center)
|
||||||
|
center = np.where(np.sum(center, axis=1) > 200)[0]
|
||||||
|
up, down = center[0], center[-1]
|
||||||
|
image = image[up:down, :, :]
|
||||||
|
return image
|
||||||
|
|
||||||
def format_result(self, result: str) -> int:
|
def format_result(self, result: str) -> int:
|
||||||
res = re.search(r'第([一二三四五六七八九十])世界', result)
|
res = re.search(r'第([一二三四五六七八九十])世界', result)
|
||||||
if res:
|
if res:
|
||||||
|
Loading…
Reference in New Issue
Block a user