mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-15 22:19:18 +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',
|
||||
share=Button(
|
||||
file='./assets/share/rogue/entry/OCR_WORLD.png',
|
||||
area=(488, 339, 718, 371),
|
||||
search=(468, 319, 738, 391),
|
||||
color=(45, 44, 68),
|
||||
button=(488, 339, 718, 371),
|
||||
area=(488, 339, 718, 395),
|
||||
search=(468, 319, 738, 415),
|
||||
color=(38, 35, 64),
|
||||
button=(488, 339, 718, 395),
|
||||
),
|
||||
)
|
||||
THEME_DLC = ButtonWrapper(
|
||||
|
@ -1,7 +1,11 @@
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import color_similarity_2d
|
||||
from module.exception import RequestHumanTakeover, ScriptError
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Ocr
|
||||
@ -67,6 +71,16 @@ def chinese_to_arabic(chinese_number: str) -> int:
|
||||
|
||||
|
||||
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:
|
||||
res = re.search(r'第([一二三四五六七八九十])世界', result)
|
||||
if res:
|
||||
|
Loading…
Reference in New Issue
Block a user