Made goal recognition NumPy 1.6.0 compatible
This commit is contained in:
@@ -61,14 +61,15 @@ class GoalFinder(object):
|
|||||||
return thr
|
return thr
|
||||||
|
|
||||||
def goal_similarity(self, contour):
|
def goal_similarity(self, contour):
|
||||||
contour = contour.squeeze(axis=1)
|
hull = cv2.convexHull(contour).squeeze()
|
||||||
hull = cv2.convexHull(contour).squeeze(axis=1)
|
|
||||||
len_h = cv2.arcLength(hull, True)
|
len_h = cv2.arcLength(hull, True)
|
||||||
|
|
||||||
# Wild assumption that the goal should lie close to its
|
# Supporting points of goal contour should lie close to its
|
||||||
# enclosing convex hull
|
# enclosing convex hull
|
||||||
shape_sim = np.linalg.norm(contour[:,None] - hull,
|
distances = np.array([[np.sqrt(np.sum(point**2)) for point in node]
|
||||||
axis=2).min(axis=1).sum() / len_h
|
for node in contour - hull])
|
||||||
|
min_dist = np.array([d.min() for d in distances])
|
||||||
|
shape_sim = min_dist.sum() / len_h
|
||||||
|
|
||||||
# Wild assumption that the area of the goal is rather small
|
# Wild assumption that the area of the goal is rather small
|
||||||
# compared to its enclosing convex hull
|
# compared to its enclosing convex hull
|
||||||
|
|||||||
Reference in New Issue
Block a user