sports2d 0.7.0__py3-none-any.whl → 0.7.2__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.
@@ -58,12 +58,14 @@ def test_workflow():
58
58
  demo_cmd = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False"]
59
59
  subprocess.run(demo_cmd, check=True, capture_output=True, text=True, encoding='utf-8')
60
60
 
61
- # With no pixels to meters conversion, no multiperson, lightweight mode, detection frequency, time range and slowmo factor
61
+ # With no pixels to meters conversion, no multiperson, lightweight mode, detection frequency, slowmo factor, gaussian filter, RTMO body pose model
62
62
  demo_cmd2 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False",
63
63
  "--to_meters", "False",
64
64
  "--multiperson", "False",
65
65
  "--mode", "lightweight", "--det_frequency", "50",
66
- "--time_range", "1.2", "2.7", "--slowmo_factor", "4"]
66
+ "--slowmo_factor", "4",
67
+ "--filter_type", "gaussian",
68
+ "--pose_model", "body", "--mode", """{'pose_class':'RTMO', 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.zip', 'pose_input_size':[640, 640]}"""]
67
69
  subprocess.run(demo_cmd2, check=True, capture_output=True, text=True, encoding='utf-8')
68
70
 
69
71
  # With a time range, inverse kinematics, marker augmentation, body pose_model and custom RTMO mode
@@ -71,9 +73,8 @@ def test_workflow():
71
73
  "--time_range", "1.2", "2.7",
72
74
  "--do_ik", "True", "--use_augmentation", "True",
73
75
  "--px_to_m_from_person_id", "1", "--px_to_m_person_height", "1.65",
74
- "--visible_side", "left", "front", "--participant_mass", "55.0", "67.0",
75
- "--pose_model", "body", "--mode", """{'pose_class':'RTMO', 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.zip', 'pose_input_size':[640, 640]}"""]
76
- subprocess.run(demo_cmd3, check=True, capture_output=True, text=True)
76
+ "--visible_side", "front", "auto", "--participant_mass", "55.0", "67.0"]
77
+ subprocess.run(demo_cmd3, check=True, capture_output=True, text=True, encoding='utf-8')
77
78
 
78
79
  # From config file
79
80
  cli_config_path = Path(__file__).resolve().parent.parent / 'Demo' / 'Config_demo.toml'
Sports2D/process.py CHANGED
@@ -625,7 +625,7 @@ def trc_data_from_XYZtime(X, Y, Z, time):
625
625
  '''
626
626
 
627
627
  trc_data = pd.concat([pd.concat([X.iloc[:,kpt], Y.iloc[:,kpt], Z.iloc[:,kpt]], axis=1) for kpt in range(len(X.columns))], axis=1)
628
- trc_data.insert(0, 't', time)
628
+ trc_data.insert(0, 'time', time)
629
629
 
630
630
  return trc_data
631
631
 
@@ -928,6 +928,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
928
928
  px_to_m_from_person_id = int(config_dict.get('project').get('px_to_m_from_person_id'))
929
929
  px_to_m_person_height_m = config_dict.get('project').get('px_to_m_person_height')
930
930
  visible_side = config_dict.get('project').get('visible_side')
931
+ if isinstance(visible_side, str): visible_side = [visible_side]
931
932
  # Pose from file
932
933
  load_trc_px = config_dict.get('project').get('load_trc_px')
933
934
  if load_trc_px == '': load_trc_px = None
@@ -1127,12 +1128,18 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1127
1128
  logging.error(f'\n{load_trc_px} file needs to be in px, not in meters.')
1128
1129
  logging.info(f'\nUsing a pose file instead of running pose estimation and tracking: {load_trc_px}.')
1129
1130
  # Load pose file in px
1130
- Q_coords, _, _, keypoints_names, _ = read_trc(load_trc_px)
1131
+ Q_coords, _, time_col, keypoints_names, _ = read_trc(load_trc_px)
1132
+
1131
1133
  keypoints_ids = [i for i in range(len(keypoints_names))]
1132
1134
  keypoints_all, scores_all = load_pose_file(Q_coords)
1133
1135
  for pre, _, node in RenderTree(pose_model):
1134
1136
  if node.name in keypoints_names:
1135
1137
  node.id = keypoints_names.index(node.name)
1138
+ if time_range:
1139
+ frame_range = [abs(time_col - time_range[0]).idxmin(), abs(time_col - time_range[1]).idxmin()+1]
1140
+ else:
1141
+ frame_range = [0, len(Q_coords)]
1142
+ frame_iterator = tqdm(range(*frame_range))
1136
1143
 
1137
1144
  else:
1138
1145
  # Retrieve keypoint names from model
@@ -1336,7 +1343,10 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1336
1343
  all_frames_scores = make_homogeneous(all_frames_scores)
1337
1344
 
1338
1345
  frame_range = [0,frame_count] if video_file == 'webcam' else frame_range
1339
- all_frames_time = pd.Series(np.linspace(frame_range[0]/fps, frame_range[1]/fps, frame_count+1), name='time')
1346
+ if not load_trc_px:
1347
+ all_frames_time = pd.Series(np.linspace(frame_range[0]/fps, frame_range[1]/fps, frame_count-frame_range[0]+1), name='time')
1348
+ else:
1349
+ all_frames_time = time_col
1340
1350
  if not multiperson:
1341
1351
  px_to_m_from_person_id = get_personID_with_highest_scores(all_frames_scores)
1342
1352
  detected_persons = [px_to_m_from_person_id]
@@ -1475,7 +1485,6 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1475
1485
  if not np.array(trc_data[i].iloc[:,1:] ==0).all():
1476
1486
  # Automatically determine visible side
1477
1487
  visible_side_i = visible_side[i] if len(visible_side)>i else 'auto' # set to 'auto' if list too short
1478
-
1479
1488
  # Set to 'front' if slope of X values between [-5,5]
1480
1489
  if visible_side_i == 'auto':
1481
1490
  try:
@@ -1648,7 +1657,11 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1648
1657
  logging.warning('Skipping marker augmentation and inverse kinematics as to_meters was set to False.')
1649
1658
  else:
1650
1659
  # move all trc files containing _m_ string to pose3d_dir
1651
- for trc_file in output_dir.glob('*_m_*.trc'):
1660
+ if not load_trc_px:
1661
+ trc_list = output_dir.glob('*_m_*.trc')
1662
+ else:
1663
+ trc_list = [pose_path_person_m_i]
1664
+ for trc_file in trc_list:
1652
1665
  if (pose3d_dir/trc_file.name).exists():
1653
1666
  os.remove(pose3d_dir/trc_file.name)
1654
1667
  shutil.move(trc_file, pose3d_dir)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sports2d
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Detect pose and compute 2D joint angles from a video.
5
5
  Home-page: https://github.com/davidpagnon/Sports2D
6
6
  Author: David Pagnon
@@ -1,16 +1,16 @@
1
1
  Sports2D/Sports2D.py,sha256=eWOz-7HQiwRu7Xl0_bPTlg9meOW635x197WL9QrKfoU,29719
2
2
  Sports2D/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
3
- Sports2D/process.py,sha256=nuNOwNJCF8dduUOOuoOYxjDpO2J5T9dEjrLYPLuuz5Q,87391
3
+ Sports2D/process.py,sha256=4Ce22jOTutlGZoPEz5vMp2g4RQUGQSByKQj_QV3UHzo,87916
4
4
  Sports2D/Demo/Config_demo.toml,sha256=S7cBtdob9zxA6deicPY1ZEQicTYeaByet5gSvRmkG00,13854
5
5
  Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
6
6
  Sports2D/Utilities/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
7
7
  Sports2D/Utilities/common.py,sha256=OKyjBuXoZK0O34vuGeXzVrWpsyx6DI219L-yuS-iQTU,48254
8
8
  Sports2D/Utilities/filter.py,sha256=8mVefMjDzxmh9a30eNtIrUuK_mUKoOJ2Nr-OzcQKkKM,4922
9
9
  Sports2D/Utilities/skeletons.py,sha256=WObRPHpCj5Q2WpspzFRy1gvAX-EZD9WyA9K-kqL4YRo,40076
10
- Sports2D/Utilities/tests.py,sha256=mE05fRL2hGGI0VD4kb_GmLsucCvyVPfOxohUK3I96RE,3516
11
- sports2d-0.7.0.dist-info/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
12
- sports2d-0.7.0.dist-info/METADATA,sha256=ywXZgpFzd2T2LTD8TmSDtIMv9uJQfAH3RpUgRAwMY68,38518
13
- sports2d-0.7.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
14
- sports2d-0.7.0.dist-info/entry_points.txt,sha256=h2CJTuydtNf8JyaLoWxWl5HTSIxx5Ra_FSiSGQsf7Sk,52
15
- sports2d-0.7.0.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
16
- sports2d-0.7.0.dist-info/RECORD,,
10
+ Sports2D/Utilities/tests.py,sha256=mzs69p5ZIGiOX6co2qwQmO09LhJLex3yujcUWC6p4Bw,3573
11
+ sports2d-0.7.2.dist-info/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
12
+ sports2d-0.7.2.dist-info/METADATA,sha256=YoQQ1p6p0fOEk12nVhaVvnkjo0dleyG46L-vsLTpxJw,38518
13
+ sports2d-0.7.2.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
14
+ sports2d-0.7.2.dist-info/entry_points.txt,sha256=h2CJTuydtNf8JyaLoWxWl5HTSIxx5Ra_FSiSGQsf7Sk,52
15
+ sports2d-0.7.2.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
16
+ sports2d-0.7.2.dist-info/RECORD,,