#!/usr/bin/env python # coding: utf-8 # ## Import # In[7]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import sys laurie_DIR = '' sys.path.append(laurie_DIR + '/LaurieOnTracking-master') import Metrica_Viz as mviz convert_DIR = '' sys.path.append(convert_DIR + '/lastrow_to_friendsoftracking-master') import lastrow_to_friendsoftracking as lrfot # In[2]: lastrow_DIR = '' last_row = pd.read_csv(lastrow_DIR + '/Last-Row-master/datasets/positional_data/liverpool_2019.csv', index_col=('play', 'frame')) # ## Convert to Friends of Tracking wide format # In[3]: data_attack, data_defence = lrfot.lastrow_to_friendsoftracking(last_row) # ## Convert to Metric # In[4]: data_attack = lrfot.lastrow_to_metric_coordinates(data_attack) data_defence = lrfot.lastrow_to_metric_coordinates(data_defence) # ## Liverpool Shoot Right to Left # In[5]: data_attack, data_defence = lrfot.lastrow_to_single_playing_direction(data_attack, data_defence) # ## Checks # In[6]: # Single Frame play = 'Bayern 0 - [1] Liverpool' frame = 10 fig,ax = mviz.plot_frame( data_attack.loc[(play, frame)], data_defence.loc[(play, frame)],annotate=True ) plt.show() # In[ ]: # Video of Goal PLOTDIR = '' mviz.save_match_clip(tracking_liverpool_attack.loc[m],tracking_liverpool_defense.loc[m],PLOTDIR,fname=name,include_player_velocities=False) # In[ ]: # All Videos of Goals PLOTDIR = '' for m in tracking_liverpool_goals.index.get_level_values('play').unique(): name = m.split(" ")[0][:3].lower() + m.split(" ")[1] + m.split(" ")[-2] + m.split(" ")[-1][:3].lower() mviz.save_match_clip(tracking_liverpool_attack.loc[m],tracking_liverpool_defense.loc[m],PLOTDIR,fname=name,include_player_velocities=False)