mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Allow locking minimap init position
This commit is contained in:
parent
2854232778
commit
2e4ea37ca6
@ -47,11 +47,33 @@ class PositionPredictState:
|
||||
|
||||
|
||||
class Minimap(MapResource):
|
||||
def init_position(self, position: tuple[int | float, int | float], show_log=True):
|
||||
position_locked = None
|
||||
|
||||
def init_position(
|
||||
self,
|
||||
position: tuple[int | float, int | float],
|
||||
show_log=True,
|
||||
locked=False,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
position:
|
||||
show_log:
|
||||
locked: If true, lock search area during detection
|
||||
"""
|
||||
if show_log:
|
||||
if locked:
|
||||
logger.info(f"init_position: {position}, locked")
|
||||
else:
|
||||
logger.info(f"init_position: {position}")
|
||||
|
||||
self.position = position
|
||||
|
||||
if locked:
|
||||
self.position_locked = position
|
||||
else:
|
||||
self.position_locked = None
|
||||
|
||||
def _predict_position(self, image, scale=1.0):
|
||||
"""
|
||||
Args:
|
||||
@ -65,8 +87,11 @@ class Minimap(MapResource):
|
||||
local = cv2.resize(image, None, fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)
|
||||
size = np.array(image_size(image))
|
||||
|
||||
if sum(self.position) > 0:
|
||||
search_position = np.array(self.position, dtype=np.int64)
|
||||
position = self.position
|
||||
if self.position_locked is not None:
|
||||
position = self.position_locked
|
||||
if sum(position) > 0:
|
||||
search_position = np.array(position, dtype=np.int64)
|
||||
search_position += self.POSITION_FEATURE_PAD
|
||||
search_size = np.array(image_size(local)) * self.POSITION_SEARCH_RADIUS
|
||||
search_half = (search_size // 2).astype(np.int64)
|
||||
|
Loading…
Reference in New Issue
Block a user