删除RecognizeError
This commit is contained in:
parent
fee5eaccd5
commit
df7f58bca0
2 changed files with 4 additions and 26 deletions
|
@ -17,10 +17,6 @@ from mower.utils.vector import clamp_scope, va
|
||||||
from .data import color, template_matching, template_matching_score
|
from .data import color, template_matching, template_matching_score
|
||||||
|
|
||||||
|
|
||||||
class RecognizeError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Recognizer:
|
class Recognizer:
|
||||||
def __init__(self, image: Optional[tp.Image] = None) -> None:
|
def __init__(self, image: Optional[tp.Image] = None) -> None:
|
||||||
self.w = 1920
|
self.w = 1920
|
||||||
|
|
|
@ -64,7 +64,7 @@ from mower.utils.email import send_message
|
||||||
from mower.utils.image import cropimg, diff_ratio, loadres, thres2
|
from mower.utils.image import cropimg, diff_ratio, loadres, thres2
|
||||||
from mower.utils.log import logger
|
from mower.utils.log import logger
|
||||||
from mower.utils.matcher import GOOD_DISTANCE_LIMIT, flann, keypoints_scale_invariant
|
from mower.utils.matcher import GOOD_DISTANCE_LIMIT, flann, keypoints_scale_invariant
|
||||||
from mower.utils.recognize import RecognizeError, Scene
|
from mower.utils.recognize import Scene
|
||||||
from mower.utils.traceback import caller_info
|
from mower.utils.traceback import caller_info
|
||||||
from mower.utils.vector import clamp_vector
|
from mower.utils.vector import clamp_vector
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class BaseSolver:
|
||||||
) -> tp.Coordinate:
|
) -> tp.Coordinate:
|
||||||
"""get the pos form tp.Location"""
|
"""get the pos form tp.Location"""
|
||||||
if poly is None:
|
if poly is None:
|
||||||
raise RecognizeError("poly is empty")
|
raise Exception("poly is empty")
|
||||||
elif len(poly) == 4:
|
elif len(poly) == 4:
|
||||||
# tp.Rectangle
|
# tp.Rectangle
|
||||||
x = (
|
x = (
|
||||||
|
@ -225,14 +225,14 @@ class BaseSolver:
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
MowerExit: 停止运行
|
MowerExit: 停止运行
|
||||||
RecognizeError: 未识别到元素
|
Exception: 未识别到元素
|
||||||
"""
|
"""
|
||||||
if config.stop_mower.is_set():
|
if config.stop_mower.is_set():
|
||||||
raise MowerExit
|
raise MowerExit
|
||||||
if isinstance(name, str):
|
if isinstance(name, str):
|
||||||
pos = self.find(name)
|
pos = self.find(name)
|
||||||
if pos is None:
|
if pos is None:
|
||||||
raise RecognizeError(f"未识别到{name}元素")
|
raise Exception(f"未识别到{name}元素")
|
||||||
else:
|
else:
|
||||||
pos = name
|
pos = name
|
||||||
config.tap_info = None, None
|
config.tap_info = None, None
|
||||||
|
@ -546,24 +546,6 @@ class BaseSolver:
|
||||||
"""get the current scene in the game"""
|
"""get the current scene in the game"""
|
||||||
return config.recog.get_scene()
|
return config.recog.get_scene()
|
||||||
|
|
||||||
def ra_scene(self) -> int:
|
|
||||||
"""
|
|
||||||
生息演算场景识别
|
|
||||||
"""
|
|
||||||
return config.recog.get_ra_scene()
|
|
||||||
|
|
||||||
def sf_scene(self) -> int:
|
|
||||||
"""
|
|
||||||
隐秘战线场景识别
|
|
||||||
"""
|
|
||||||
return config.recog.get_sf_scene()
|
|
||||||
|
|
||||||
def train_scene(self) -> int:
|
|
||||||
"""
|
|
||||||
训练室景识别
|
|
||||||
"""
|
|
||||||
return config.recog.get_train_scene()
|
|
||||||
|
|
||||||
def solve_captcha(self, refresh=False):
|
def solve_captcha(self, refresh=False):
|
||||||
th = thres2(config.recog.gray, 254)
|
th = thres2(config.recog.gray, 254)
|
||||||
pos = np.nonzero(th)
|
pos = np.nonzero(th)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue