mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Cropping outside of direction area
This commit is contained in:
parent
271bdc9e1c
commit
8648644c2f
@ -6,6 +6,7 @@ import numpy as np
|
|||||||
from scipy import signal
|
from scipy import signal
|
||||||
|
|
||||||
from module.base.utils import (
|
from module.base.utils import (
|
||||||
|
area_limit,
|
||||||
area_offset,
|
area_offset,
|
||||||
area_pad,
|
area_pad,
|
||||||
color_similarity_2d,
|
color_similarity_2d,
|
||||||
@ -46,8 +47,9 @@ class PositionPredictState:
|
|||||||
|
|
||||||
|
|
||||||
class Minimap(MapResource):
|
class Minimap(MapResource):
|
||||||
def init_position(self, position: tuple[int | float, int | float]):
|
def init_position(self, position: tuple[int | float, int | float], show_log=True):
|
||||||
logger.info(f"init_position: {position}")
|
if show_log:
|
||||||
|
logger.info(f"init_position: {position}")
|
||||||
self.position = position
|
self.position = position
|
||||||
|
|
||||||
def _predict_position(self, image, scale=1.0):
|
def _predict_position(self, image, scale=1.0):
|
||||||
@ -211,6 +213,7 @@ class Minimap(MapResource):
|
|||||||
image = color_similarity_2d(image, color=self.DIRECTION_ARROW_COLOR)
|
image = color_similarity_2d(image, color=self.DIRECTION_ARROW_COLOR)
|
||||||
try:
|
try:
|
||||||
area = area_pad(get_bbox(image, threshold=128), pad=-1)
|
area = area_pad(get_bbox(image, threshold=128), pad=-1)
|
||||||
|
area = area_limit(area, (0, 0, *image_size(image)))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# IndexError: index 0 is out of bounds for axis 0 with size 0
|
# IndexError: index 0 is out of bounds for axis 0 with size 0
|
||||||
logger.warning('No direction arrow on minimap')
|
logger.warning('No direction arrow on minimap')
|
||||||
@ -253,7 +256,7 @@ class Minimap(MapResource):
|
|||||||
precise_loca = degree // 8 * 8 - 8 + precise_loca[0]
|
precise_loca = degree // 8 * 8 - 8 + precise_loca[0]
|
||||||
|
|
||||||
self.direction_similarity = round(precise_sim, 3)
|
self.direction_similarity = round(precise_sim, 3)
|
||||||
self.direction = precise_loca % 360
|
self.direction = round(precise_loca % 360, 1)
|
||||||
|
|
||||||
def update_rotation(self, image):
|
def update_rotation(self, image):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user