Fixed critical bug in goal center detection

This commit is contained in:
2018-06-30 17:11:33 +02:00
parent 6d9d522692
commit b9d6898691
5 changed files with 12 additions and 6 deletions

View File

@@ -161,7 +161,7 @@ if __name__ == '__main__':
striker.mover.kick(fancy=True, foot='L') striker.mover.kick(fancy=True, foot='L')
##striker.speak("Nice kick. Let's do a dance") ##striker.speak("Nice kick. Let's do a dance")
#striker.mover.dance() #striker.mover.dance()
sleep(2) sleep(4)
break break
finally: finally:
striker.close() striker.close()

View File

@@ -111,6 +111,11 @@ if __name__ == '__main__':
ball = ball_finder.find(ball_frame) ball = ball_finder.find(ball_frame)
goal = goal_finder.find(goal_frame) goal = goal_finder.find(goal_frame)
if goal is not None:
print(goal)
print('LR post', goal_finder.left_right_post(goal))
print('----')
ball_frame = ball_finder.draw(ball_frame, ball) ball_frame = ball_finder.draw(ball_frame, ball)
goal_frame = goal_finder.draw(goal_frame, goal) goal_frame = goal_finder.draw(goal_frame, goal)

View File

@@ -118,7 +118,7 @@ class GoalFinder(object):
return goal return goal
def left_right_post(self, contour): def left_right_post(self, contour):
return contour[:,0].min(), contour[:,0].max() return contour[...,0].min(), contour[...,0].max()
def goal_center(self, contour): def goal_center(self, contour):
l, r = self.left_right_post(contour) l, r = self.left_right_post(contour)

View File

@@ -11,19 +11,19 @@
255 255
] ]
], ],
"cam": 1,
"goal": [ "goal": [
[ [
0, 0,
0, 0,
114 100
], ],
[ [
180, 180,
49, 65,
255 255
] ]
], ],
"fps": 10,
"res": 2, "res": 2,
"ball_min_radius": 0.01, "ball_min_radius": 0.01,
"field": [ "field": [
@@ -38,7 +38,7 @@
255 255
] ]
], ],
"cam": 1, "fps": 10,
"ip": "192.168.0.11", "ip": "192.168.0.11",
"port": 9559 "port": 9559
} }

View File

@@ -294,6 +294,7 @@ class Striker(object):
self.speak("Turn to ball") self.speak("Turn to ball")
self.turn_to_ball(x, y, tol=0.15) self.turn_to_ball(x, y, tol=0.15)
self.speak('Trying to find the goal') self.speak('Trying to find the goal')
sleep(0.2)
goal_center_x = self.goal_search() goal_center_x = self.goal_search()
self.speak('Goal found') self.speak('Goal found')