mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 09:48:20 +08:00
Fix: Handle new stage entrance icon
- Fix in_stage detection on slow pc
This commit is contained in:
@@ -51,7 +51,7 @@ ASSETS = Assets()
|
||||
|
||||
class Points:
|
||||
def __init__(self, points, config):
|
||||
if points is None:
|
||||
if points is None or len(points) == 0:
|
||||
self._bool = False
|
||||
self.points = None
|
||||
else:
|
||||
@@ -59,8 +59,8 @@ class Points:
|
||||
self.points = np.array(points)
|
||||
if len(self.points.shape) == 1:
|
||||
self.points = np.array([self.points])
|
||||
self.x, self.y = self.points.T
|
||||
self.config = config
|
||||
self.x, self.y = self.points.T
|
||||
|
||||
def __str__(self):
|
||||
return str(self.points)
|
||||
@@ -72,7 +72,10 @@ class Points:
|
||||
return self.points[item]
|
||||
|
||||
def __len__(self):
|
||||
return len(self.points)
|
||||
if self:
|
||||
return len(self.points)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def __bool__(self):
|
||||
return self._bool
|
||||
@@ -88,6 +91,29 @@ class Points:
|
||||
lines = np.array([rho, theta]).T
|
||||
return Lines(lines, is_horizontal=False, config=self.config)
|
||||
|
||||
def mean(self):
|
||||
if not self:
|
||||
return None
|
||||
|
||||
return np.round(np.mean(self.points, axis=0)).astype(int)
|
||||
|
||||
def group(self, threshold=3):
|
||||
if not self:
|
||||
return np.array([])
|
||||
groups = []
|
||||
points = self.points
|
||||
|
||||
while len(points):
|
||||
if len(points) == 1:
|
||||
return np.array([points[0]])
|
||||
p0, p1 = points[0], points[1:]
|
||||
distance = np.sum(np.abs(p1 - p0), axis=1)
|
||||
new = Points(np.append(p1[distance <= threshold], [p0], axis=0), config=self.config).mean().tolist()
|
||||
groups.append(new)
|
||||
points = p1[distance > threshold]
|
||||
|
||||
return np.array(groups)
|
||||
|
||||
|
||||
class Lines:
|
||||
def __init__(self, lines, is_horizontal, config):
|
||||
|
||||
Reference in New Issue
Block a user