Even better video capture

This commit is contained in:
2018-06-30 15:22:57 +02:00
parent 784560753d
commit 9b400c0a62
3 changed files with 51 additions and 53 deletions

View File

@@ -7,54 +7,6 @@ from .striker import Striker
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__':
try: # Hit Ctrl-C to stop, cleanup and exit
@@ -213,3 +165,50 @@ if __name__ == '__main__':
finally:
striker.close()
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 | |
# | | |
# +---------------------------------+---------+
#
# _______________________________________________________

View File

@@ -65,7 +65,6 @@ class NaoImageReader(object):
self.fps,
(self.res[1], self.res[0]))
for frame in self.recording:
print('.')
vf.write(frame)
vf.release()

View File

@@ -26,20 +26,20 @@ class Striker(object):
# Sight
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(
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
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'
)
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'
)
self.pov_thread = Thread(target=self._pov)