sports2d 0.8.11__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 CHANGED
@@ -83,6 +83,7 @@ from Sports2D.Utilities import filter
83
83
  from Sports2D.Utilities.common import *
84
84
  from Pose2Sim.common import *
85
85
  from Pose2Sim.skeletons import *
86
+ from Pose2Sim.triangulation import indices_of_first_last_non_nan_chunks
86
87
 
87
88
  DEFAULT_MASS = 70
88
89
  DEFAULT_HEIGHT = 1.7
@@ -495,24 +496,25 @@ def draw_angles(img, valid_X, valid_Y, valid_angles, valid_X_flipped, keypoints_
495
496
  right_angle = True if ang_params[2]==90 else False
496
497
 
497
498
  # Draw angle
498
- if len(ang_coords) == 2: # segment angle
499
- app_point, vec = draw_segment_angle(img, ang_coords, flip)
500
- else: # joint angle
501
- app_point, vec1, vec2 = draw_joint_angle(img, ang_coords, flip, right_angle)
502
-
503
- # Write angle on body
504
- if 'body' in display_angle_values_on:
499
+ if not np.any(np.isnan(ang_coords)):
505
500
  if len(ang_coords) == 2: # segment angle
506
- write_angle_on_body(img, ang, app_point, vec, np.array([1,0]), dist=20, color=(255,255,255), fontSize=fontSize, thickness=thickness)
501
+ app_point, vec = draw_segment_angle(img, ang_coords, flip)
507
502
  else: # joint angle
508
- write_angle_on_body(img, ang, app_point, vec1, vec2, dist=40, color=(0,255,0), fontSize=fontSize, thickness=thickness)
509
-
510
- # Write angle as a list on image with progress bar
511
- if 'list' in display_angle_values_on:
512
- if len(ang_coords) == 2: # segment angle
513
- 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)
514
- else:
515
- 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)
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)
516
518
 
517
519
  return img
518
520
 
@@ -789,14 +791,15 @@ def pose_plots(trc_data_unfiltered, trc_data, person_id):
789
791
  OUTPUT:
790
792
  - matplotlib window with tabbed figures for each keypoint
791
793
  '''
792
- os_name = platform.system()
793
794
 
795
+ os_name = platform.system()
794
796
  if os_name == 'Windows':
795
797
  mpl.use('qt5agg') # windows
798
+
796
799
  mpl.rc('figure', max_open_warning=0)
797
800
 
798
801
  keypoints_names = trc_data.columns[1::3]
799
-
802
+
800
803
  pw = plotWindow()
801
804
  pw.MainWindow.setWindowTitle('Person'+ str(person_id) + ' coordinates') # Main title
802
805
 
@@ -838,16 +841,22 @@ def angle_plots(angle_data_unfiltered, angle_data, person_id):
838
841
  - matplotlib window with tabbed figures for each angle
839
842
  '''
840
843
 
841
- mpl.use('qt5agg')
844
+ os_name = platform.system()
845
+ if os_name == 'Windows':
846
+ mpl.use('qt5agg') # windows
842
847
  mpl.rc('figure', max_open_warning=0)
843
848
 
844
849
  angles_names = angle_data.columns[1:]
845
-
850
+
846
851
  pw = plotWindow()
847
852
  pw.MainWindow.setWindowTitle('Person'+ str(person_id) + ' angles') # Main title
848
853
 
849
854
  for id, angle in enumerate(angles_names):
850
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
851
860
 
852
861
  ax = plt.subplot(111)
853
862
  plt.plot(angle_data_unfiltered.iloc[:,0], angle_data_unfiltered.iloc[:,id+1], label='unfiltered')
@@ -1817,9 +1826,15 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1817
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}.')
1818
1827
  all_frames_X_person_interp = all_frames_X_person.apply(interpolate_zeros_nans, axis=0, args = [interp_gap_smaller_than, 'linear'])
1819
1828
  all_frames_Y_person_interp = all_frames_Y_person.apply(interpolate_zeros_nans, axis=0, args = [interp_gap_smaller_than, 'linear'])
1829
+
1820
1830
  if fill_large_gaps_with.lower() == 'last_value':
1821
- all_frames_X_person_interp = all_frames_X_person_interp.ffill(axis=0).bfill(axis=0)
1822
- all_frames_Y_person_interp = all_frames_Y_person_interp.ffill(axis=0).bfill(axis=0)
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
+
1823
1838
  elif fill_large_gaps_with.lower() == 'zeros':
1824
1839
  all_frames_X_person_interp.replace(np.nan, 0, inplace=True)
1825
1840
  all_frames_Y_person_interp.replace(np.nan, 0, inplace=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sports2d
3
- Version: 0.8.11
3
+ Version: 0.8.12
4
4
  Summary: Compute 2D human pose and angles from a video or a webcam.
5
5
  Author-email: David Pagnon <contact@david-pagnon.com>
6
6
  Maintainer-email: David Pagnon <contact@david-pagnon.com>
@@ -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=pcPW5qpZzD-L-ZiRFZn3TWeywg3ojlgjhiw2FPkGodA,111598
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.11.dist-info/licenses/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
22
- sports2d-0.8.11.dist-info/METADATA,sha256=rKNwu5yaVBb4c161s5SFrGYxyJWoQdqcyzPn5YxEwGA,38443
23
- sports2d-0.8.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- sports2d-0.8.11.dist-info/entry_points.txt,sha256=V8dFDIXatz9VvoGgoHzb2wE71C9-f85K6_OjnEQlxww,108
25
- sports2d-0.8.11.dist-info/top_level.txt,sha256=cWWBiDD2WbQXMoIoN6-9et9U2t2c_ZKo2JtBqO5uN-k,17
26
- sports2d-0.8.11.dist-info/RECORD,,
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,,