sports2d 0.8.10__py3-none-any.whl → 0.8.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Sports2D/process.py +44 -23
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/METADATA +1 -1
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/RECORD +7 -7
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/WHEEL +0 -0
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/entry_points.txt +0 -0
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/licenses/LICENSE +0 -0
- {sports2d-0.8.10.dist-info → sports2d-0.8.12.dist-info}/top_level.txt +0 -0
Sports2D/process.py
CHANGED
|
@@ -60,6 +60,7 @@ import copy
|
|
|
60
60
|
import shutil
|
|
61
61
|
import os
|
|
62
62
|
import re
|
|
63
|
+
import platform
|
|
63
64
|
from importlib.metadata import version
|
|
64
65
|
from datetime import datetime
|
|
65
66
|
import itertools as it
|
|
@@ -82,6 +83,7 @@ from Sports2D.Utilities import filter
|
|
|
82
83
|
from Sports2D.Utilities.common import *
|
|
83
84
|
from Pose2Sim.common import *
|
|
84
85
|
from Pose2Sim.skeletons import *
|
|
86
|
+
from Pose2Sim.triangulation import indices_of_first_last_non_nan_chunks
|
|
85
87
|
|
|
86
88
|
DEFAULT_MASS = 70
|
|
87
89
|
DEFAULT_HEIGHT = 1.7
|
|
@@ -494,24 +496,25 @@ def draw_angles(img, valid_X, valid_Y, valid_angles, valid_X_flipped, keypoints_
|
|
|
494
496
|
right_angle = True if ang_params[2]==90 else False
|
|
495
497
|
|
|
496
498
|
# Draw angle
|
|
497
|
-
if
|
|
498
|
-
app_point, vec = draw_segment_angle(img, ang_coords, flip)
|
|
499
|
-
else: # joint angle
|
|
500
|
-
app_point, vec1, vec2 = draw_joint_angle(img, ang_coords, flip, right_angle)
|
|
501
|
-
|
|
502
|
-
# Write angle on body
|
|
503
|
-
if 'body' in display_angle_values_on:
|
|
499
|
+
if not np.any(np.isnan(ang_coords)):
|
|
504
500
|
if len(ang_coords) == 2: # segment angle
|
|
505
|
-
|
|
501
|
+
app_point, vec = draw_segment_angle(img, ang_coords, flip)
|
|
506
502
|
else: # joint angle
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
503
|
+
app_point, vec1, vec2 = draw_joint_angle(img, ang_coords, flip, right_angle)
|
|
504
|
+
|
|
505
|
+
# Write angle on body
|
|
506
|
+
if 'body' in display_angle_values_on:
|
|
507
|
+
if len(ang_coords) == 2: # segment angle
|
|
508
|
+
write_angle_on_body(img, ang, app_point, vec, np.array([1,0]), dist=20, color=(255,255,255), fontSize=fontSize, thickness=thickness)
|
|
509
|
+
else: # joint angle
|
|
510
|
+
write_angle_on_body(img, ang, app_point, vec1, vec2, dist=40, color=(0,255,0), fontSize=fontSize, thickness=thickness)
|
|
511
|
+
|
|
512
|
+
# Write angle as a list on image with progress bar
|
|
513
|
+
if 'list' in display_angle_values_on:
|
|
514
|
+
if len(ang_coords) == 2: # segment angle
|
|
515
|
+
ang_label_line = write_angle_as_list(img, ang, ang_name, person_label_position, ang_label_line, color = (255,255,255), fontSize=fontSize, thickness=thickness)
|
|
516
|
+
else:
|
|
517
|
+
ang_label_line = write_angle_as_list(img, ang, ang_name, person_label_position, ang_label_line, color = (0,255,0), fontSize=fontSize, thickness=thickness)
|
|
515
518
|
|
|
516
519
|
return img
|
|
517
520
|
|
|
@@ -788,8 +791,11 @@ def pose_plots(trc_data_unfiltered, trc_data, person_id):
|
|
|
788
791
|
OUTPUT:
|
|
789
792
|
- matplotlib window with tabbed figures for each keypoint
|
|
790
793
|
'''
|
|
791
|
-
|
|
792
|
-
|
|
794
|
+
|
|
795
|
+
os_name = platform.system()
|
|
796
|
+
if os_name == 'Windows':
|
|
797
|
+
mpl.use('qt5agg') # windows
|
|
798
|
+
|
|
793
799
|
mpl.rc('figure', max_open_warning=0)
|
|
794
800
|
|
|
795
801
|
keypoints_names = trc_data.columns[1::3]
|
|
@@ -799,7 +805,10 @@ def pose_plots(trc_data_unfiltered, trc_data, person_id):
|
|
|
799
805
|
|
|
800
806
|
for id, keypoint in enumerate(keypoints_names):
|
|
801
807
|
f = plt.figure()
|
|
802
|
-
|
|
808
|
+
if os_name == 'Windows':
|
|
809
|
+
f.canvas.manager.window.setWindowTitle(keypoint + ' Plot') # windows
|
|
810
|
+
elif os_name == 'Darwin': # macOS
|
|
811
|
+
f.canvas.manager.set_window_title(keypoint + ' Plot') # mac
|
|
803
812
|
|
|
804
813
|
axX = plt.subplot(211)
|
|
805
814
|
plt.plot(trc_data_unfiltered.iloc[:,0], trc_data_unfiltered.iloc[:,id*3+1], label='unfiltered')
|
|
@@ -832,16 +841,22 @@ def angle_plots(angle_data_unfiltered, angle_data, person_id):
|
|
|
832
841
|
- matplotlib window with tabbed figures for each angle
|
|
833
842
|
'''
|
|
834
843
|
|
|
835
|
-
|
|
844
|
+
os_name = platform.system()
|
|
845
|
+
if os_name == 'Windows':
|
|
846
|
+
mpl.use('qt5agg') # windows
|
|
836
847
|
mpl.rc('figure', max_open_warning=0)
|
|
837
848
|
|
|
838
849
|
angles_names = angle_data.columns[1:]
|
|
839
|
-
|
|
850
|
+
|
|
840
851
|
pw = plotWindow()
|
|
841
852
|
pw.MainWindow.setWindowTitle('Person'+ str(person_id) + ' angles') # Main title
|
|
842
853
|
|
|
843
854
|
for id, angle in enumerate(angles_names):
|
|
844
855
|
f = plt.figure()
|
|
856
|
+
if os_name == 'Windows':
|
|
857
|
+
f.canvas.manager.window.setWindowTitle(angle + ' Plot') # windows
|
|
858
|
+
elif os_name == 'Darwin': # macOS
|
|
859
|
+
f.canvas.manager.set_window_title(angle + ' Plot') # mac
|
|
845
860
|
|
|
846
861
|
ax = plt.subplot(111)
|
|
847
862
|
plt.plot(angle_data_unfiltered.iloc[:,0], angle_data_unfiltered.iloc[:,id+1], label='unfiltered')
|
|
@@ -1811,9 +1826,15 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
1811
1826
|
logging.info(f'- Person {i}: Interpolating missing sequences if they are smaller than {interp_gap_smaller_than} frames. Large gaps filled with {fill_large_gaps_with}.')
|
|
1812
1827
|
all_frames_X_person_interp = all_frames_X_person.apply(interpolate_zeros_nans, axis=0, args = [interp_gap_smaller_than, 'linear'])
|
|
1813
1828
|
all_frames_Y_person_interp = all_frames_Y_person.apply(interpolate_zeros_nans, axis=0, args = [interp_gap_smaller_than, 'linear'])
|
|
1829
|
+
|
|
1814
1830
|
if fill_large_gaps_with.lower() == 'last_value':
|
|
1815
|
-
|
|
1816
|
-
|
|
1831
|
+
for col in all_frames_X_person_interp.columns:
|
|
1832
|
+
first_run_start, last_run_end = indices_of_first_last_non_nan_chunks(all_frames_Y_person_interp[col])
|
|
1833
|
+
for coord_df in [all_frames_X_person_interp, all_frames_Y_person_interp]:
|
|
1834
|
+
coord_df.loc[:first_run_start, col] = np.nan
|
|
1835
|
+
coord_df.loc[last_run_end:, col] = np.nan
|
|
1836
|
+
coord_df.loc[first_run_start:last_run_end, col] = coord_df.loc[first_run_start:last_run_end, col].ffill().bfill()
|
|
1837
|
+
|
|
1817
1838
|
elif fill_large_gaps_with.lower() == 'zeros':
|
|
1818
1839
|
all_frames_X_person_interp.replace(np.nan, 0, inplace=True)
|
|
1819
1840
|
all_frames_Y_person_interp.replace(np.nan, 0, inplace=True)
|
|
@@ -11,16 +11,16 @@ Content/sports2d_opensim.gif,sha256=XP1AcjqhbGcJknXUoNJjPWAwaM9ahZafbDgLWvzKJs4,
|
|
|
11
11
|
Sports2D/Sports2D.ipynb,sha256=VnOVjIl6ndnCJTT13L4W5qTw4T-TQDF3jt3-wxnXDqM,2427047
|
|
12
12
|
Sports2D/Sports2D.py,sha256=tbQi_d6GXMqFkSd1_FRxyl6oA4CXEJH0g-lEskmR4mI,33521
|
|
13
13
|
Sports2D/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
|
|
14
|
-
Sports2D/process.py,sha256=
|
|
14
|
+
Sports2D/process.py,sha256=7qmRF8xi41A-_O5aeuvM1WTJLXCLzwWUvT5klku3qJE,112492
|
|
15
15
|
Sports2D/Demo/Config_demo.toml,sha256=jiPGr6JbePu1tItgRxdAu45mwFqr3RcIi_tfhO2ik1g,14027
|
|
16
16
|
Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
|
|
17
17
|
Sports2D/Utilities/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
|
|
18
18
|
Sports2D/Utilities/common.py,sha256=idMRmesFv5BPX-5g3z5dOVa7SpS_8tNgijvGrOZlR-k,11185
|
|
19
19
|
Sports2D/Utilities/filter.py,sha256=rfZcqofjllKI_5ovZTKEAmyjOZpB_PzbAJ0P874T8Ak,4973
|
|
20
20
|
Sports2D/Utilities/tests.py,sha256=3-slY2teKd78q0NzfJ2H84xRFSNXvGyDwew27oHJfrY,4740
|
|
21
|
-
sports2d-0.8.
|
|
22
|
-
sports2d-0.8.
|
|
23
|
-
sports2d-0.8.
|
|
24
|
-
sports2d-0.8.
|
|
25
|
-
sports2d-0.8.
|
|
26
|
-
sports2d-0.8.
|
|
21
|
+
sports2d-0.8.12.dist-info/licenses/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
|
|
22
|
+
sports2d-0.8.12.dist-info/METADATA,sha256=g-tjMxMWMTSwStQfCCrmr65XPFeXIv37OO3XG6MMWxY,38443
|
|
23
|
+
sports2d-0.8.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
24
|
+
sports2d-0.8.12.dist-info/entry_points.txt,sha256=V8dFDIXatz9VvoGgoHzb2wE71C9-f85K6_OjnEQlxww,108
|
|
25
|
+
sports2d-0.8.12.dist-info/top_level.txt,sha256=cWWBiDD2WbQXMoIoN6-9et9U2t2c_ZKo2JtBqO5uN-k,17
|
|
26
|
+
sports2d-0.8.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|