Even better video capture
This commit is contained in:
@@ -7,54 +7,6 @@ from .striker import Striker
|
|||||||
from .utils import read_config, InterruptDelayed
|
from .utils import read_config, InterruptDelayed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ____________________ STRIKER __________________________
|
|
||||||
#
|
|
||||||
# +----> Ball tracking (see below) <-------------+
|
|
||||||
# | |
|
|
||||||
# | | |
|
|
||||||
# | | |
|
|
||||||
# | v |
|
|
||||||
# | Ball in lower cam? |
|
|
||||||
# | / \ |
|
|
||||||
# lost | yes / \ cannot do |
|
|
||||||
# ball | v v |
|
|
||||||
# +-- Goal align Ball is only in top camera --+
|
|
||||||
# | Move closer.
|
|
||||||
# |
|
|
||||||
# successful |
|
|
||||||
# v
|
|
||||||
# Kick it! (Fancy or simple)
|
|
||||||
#
|
|
||||||
# _______________________________________________________
|
|
||||||
|
|
||||||
# ____________________ TRACKING _________________________
|
|
||||||
#
|
|
||||||
# yes
|
|
||||||
# check if ball visible ---> rotate head to the ball
|
|
||||||
# ^ | |
|
|
||||||
# | | no |
|
|
||||||
# | v |
|
|
||||||
# +--- ball scan rotation |
|
|
||||||
# | |
|
|
||||||
# | no V
|
|
||||||
# | +---------- already rotating body?
|
|
||||||
# | | |
|
|
||||||
# | v | yes
|
|
||||||
# | head angle too big? v
|
|
||||||
# | / \ head angle
|
|
||||||
# | yes / \ no is below threshold?
|
|
||||||
# | v v | |
|
|
||||||
# | stop successful | no | yes
|
|
||||||
# | moving exit | v
|
|
||||||
# +----- and start | stop rotating body
|
|
||||||
# | rotating body | |
|
|
||||||
# | | |
|
|
||||||
# +---------------------------------+---------+
|
|
||||||
#
|
|
||||||
# _______________________________________________________
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
try: # Hit Ctrl-C to stop, cleanup and exit
|
try: # Hit Ctrl-C to stop, cleanup and exit
|
||||||
@@ -213,3 +165,50 @@ if __name__ == '__main__':
|
|||||||
finally:
|
finally:
|
||||||
striker.close()
|
striker.close()
|
||||||
striker.mover.rest()
|
striker.mover.rest()
|
||||||
|
|
||||||
|
|
||||||
|
# ____________________ STRIKER __________________________
|
||||||
|
#
|
||||||
|
# +----> Ball tracking (see below) <-------------+
|
||||||
|
# | |
|
||||||
|
# | | |
|
||||||
|
# | | |
|
||||||
|
# | v |
|
||||||
|
# | Ball in lower cam? |
|
||||||
|
# | / \ |
|
||||||
|
# lost | yes / \ cannot do |
|
||||||
|
# ball | v v |
|
||||||
|
# +-- Goal align Ball is only in top camera --+
|
||||||
|
# | Move closer.
|
||||||
|
# |
|
||||||
|
# successful |
|
||||||
|
# v
|
||||||
|
# Kick it! (Fancy or simple)
|
||||||
|
#
|
||||||
|
# _______________________________________________________
|
||||||
|
|
||||||
|
# ____________________ TRACKING _________________________
|
||||||
|
#
|
||||||
|
# yes
|
||||||
|
# check if ball visible ---> rotate head to the ball
|
||||||
|
# ^ | |
|
||||||
|
# | | no |
|
||||||
|
# | v |
|
||||||
|
# +--- ball scan rotation |
|
||||||
|
# | |
|
||||||
|
# | no V
|
||||||
|
# | +---------- already rotating body?
|
||||||
|
# | | |
|
||||||
|
# | v | yes
|
||||||
|
# | head angle too big? v
|
||||||
|
# | / \ head angle
|
||||||
|
# | yes / \ no is below threshold?
|
||||||
|
# | v v | |
|
||||||
|
# | stop successful | no | yes
|
||||||
|
# | moving exit | v
|
||||||
|
# +----- and start | stop rotating body
|
||||||
|
# | rotating body | |
|
||||||
|
# | | |
|
||||||
|
# +---------------------------------+---------+
|
||||||
|
#
|
||||||
|
# _______________________________________________________
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ class NaoImageReader(object):
|
|||||||
self.fps,
|
self.fps,
|
||||||
(self.res[1], self.res[0]))
|
(self.res[1], self.res[0]))
|
||||||
for frame in self.recording:
|
for frame in self.recording:
|
||||||
print('.')
|
|
||||||
vf.write(frame)
|
vf.write(frame)
|
||||||
vf.release()
|
vf.release()
|
||||||
|
|
||||||
|
|||||||
@@ -26,20 +26,20 @@ class Striker(object):
|
|||||||
|
|
||||||
# Sight
|
# Sight
|
||||||
self.upper_camera = NaoImageReader(
|
self.upper_camera = NaoImageReader(
|
||||||
nao_ip, port=nao_port, res=res, fps=30, cam_id=0,
|
nao_ip, port=nao_port, res=res, fps=10, cam_id=0,
|
||||||
)
|
)
|
||||||
self.lower_camera = NaoImageReader(
|
self.lower_camera = NaoImageReader(
|
||||||
nao_ip, port=nao_port, res=res, fps=30, cam_id=1,
|
nao_ip, port=nao_port, res=res, fps=10, cam_id=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
# POV
|
# POV
|
||||||
self.upper_pov = NaoImageReader(
|
self.upper_pov = NaoImageReader(
|
||||||
nao_ip, port=nao_port, res=0, fps=15, cam_id=0,
|
nao_ip, port=nao_port, res=1, fps=15, cam_id=0,
|
||||||
video_file='./cam0_' + self.run_id + '.avi'
|
video_file='./cam0_' + self.run_id + '.avi'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.lower_pov = NaoImageReader(
|
self.lower_pov = NaoImageReader(
|
||||||
nao_ip, port=nao_port, res=0, fps=15, cam_id=1,
|
nao_ip, port=nao_port, res=1, fps=15, cam_id=1,
|
||||||
video_file='./cam1_' + self.run_id + '.avi'
|
video_file='./cam1_' + self.run_id + '.avi'
|
||||||
)
|
)
|
||||||
self.pov_thread = Thread(target=self._pov)
|
self.pov_thread = Thread(target=self._pov)
|
||||||
|
|||||||
Reference in New Issue
Block a user