Beispiel #1
0
def Generate_Tracab_Chance_Videos(match_OPTA, match_tb, frames_tb):
    t_init_buf = 0.5
    t_end_buf = 0.1
    match_end = frames_tb[-1].timestamp
    all_shots = [e for e in match_OPTA.hometeam.events if e.is_shot] + [e for e in match_OPTA.awayteam.events if e.is_shot]
    for shot in all_shots:
        print shot
        tstart = (shot.period_id, max(0.0,shot.time-45*(shot.period_id-1) - t_init_buf))
        tend = (shot.period_id, min(match_end,shot.time-45*(shot.period_id-1) + t_end_buf))
        frames_in_segment = vis.get_frames_between_timestamps(frames_tb,match_tb,tstart,tend)
        vis.save_match_clip(frames_in_segment,match_tb,fpath=match_OPTA.fpath+'/chances/',fname=shot.shot_id,include_player_velocities=False,description=shot.shot_descriptor)
               figax=(fig, ax))

for cf in corner_frames:
    if corners.iloc[0]['Team'] == hometeam:
        players = cf.team1_players  # home team players
        pcolor = 'r.'  # for plots
        direction_of_play = match.period_parity[
            frame.
            period] * -1  # 1 means home team is playing right->left, -1 means left-right (but switch sign for this example)
    else:
        players = cf.team0_players  # away team players
        pcolor = 'b.'
        direction_of_play = match.period_parity[frame.period]
    # iterate over attacking players and plot their positions
    for k in players.keys():  # players are indexed by their jersey numbers
        # is player in penalty area, if so plot their position.
        if players[k].pos_x * direction_of_play > penalty_area_edge and abs(
                players[k].pos_y) < penalty_area_width / 2.:
            ax.plot(players[k].pos_x * 100,
                    players[k].pos_y * 100,
                    pcolor,
                    markersize=1)

# save a movie of the corner
vis.save_match_clip(corner_frames,
                    match,
                    PLOTDIR,
                    fname='corner1',
                    include_player_velocities=False,
                    units=1.)