sports2d 0.8.1__py3-none-any.whl → 0.8.3__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.
@@ -93,7 +93,6 @@ tracking_mode = 'sports2d' # 'sports2d' or 'deepsort'. 'deepsort' is slower, har
93
93
  # More robust in crowded scenes but tricky to parametrize. More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51
94
94
  # Requires `pip install torch torchvision torchreid gdown tensorboard`
95
95
 
96
-
97
96
  # Processing parameters
98
97
  keypoint_likelihood_threshold = 0.3 # Keypoints whose likelihood is lower will not be taken into account
99
98
  average_likelihood_threshold = 0.5 # Person will be ignored if average likelihood of good keypoints is lower than this value
Sports2D/Sports2D.py CHANGED
@@ -252,7 +252,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
252
252
  'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
253
253
  'to_meters': ["M", "convert pixels to meters. true if not specified"],
254
254
  'make_c3d': ["", "Convert trc to c3d file. true if not specified"],
255
- 'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
255
+ 'floor_angle': ["", "angle of the floor (degrees). 'auto' if not specified"],
256
256
  'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
257
257
  'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
258
258
  'save_calib': ["", "save calibration file. true if not specified"],
Sports2D/process.py CHANGED
@@ -56,6 +56,7 @@ import sys
56
56
  import logging
57
57
  import json
58
58
  import ast
59
+ import copy
59
60
  import shutil
60
61
  import os
61
62
  from importlib.metadata import version
@@ -1350,10 +1351,15 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1350
1351
  close_to_zero_speed_px = config_dict.get('kinematics').get('close_to_zero_speed_px')
1351
1352
  close_to_zero_speed_m = config_dict.get('kinematics').get('close_to_zero_speed_m')
1352
1353
  if do_ik or use_augmentation:
1353
- if use_augmentation:
1354
- from Pose2Sim.markerAugmentation import augment_markers_all
1355
- if do_ik:
1356
- from Pose2Sim.kinematics import kinematics_all
1354
+ try:
1355
+ if use_augmentation:
1356
+ from Pose2Sim.markerAugmentation import augment_markers_all
1357
+ if do_ik:
1358
+ from Pose2Sim.kinematics import kinematics_all
1359
+ except ImportError:
1360
+ logging.error("OpenSim package is not installed. Please install it to use inverse kinematics or marker augmentation features (see 'Full install' section of the documentation).")
1361
+ raise ImportError("OpenSim package is not installed. Please install it to use inverse kinematics or marker augmentation features (see 'Full install' section of the documentation).")
1362
+
1357
1363
  # Create a Pose2Sim dictionary and fill in missing keys
1358
1364
  recursivedict = lambda: defaultdict(recursivedict)
1359
1365
  Pose2Sim_config_dict = recursivedict()
@@ -1428,7 +1434,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1428
1434
  backend=backend, device=device)
1429
1435
 
1430
1436
  except (json.JSONDecodeError, TypeError):
1431
- logging.warning("\nInvalid mode. Must be 'lightweight', 'balanced', 'performance', or '''{dictionary}''' of parameters within triple quotes. Make sure input_sizes are within square brackets.")
1437
+ logging.warning("Invalid mode. Must be 'lightweight', 'balanced', 'performance', or '''{dictionary}''' of parameters within triple quotes. Make sure input_sizes are within square brackets.")
1432
1438
  logging.warning('Using the default "balanced" mode.')
1433
1439
  mode = 'balanced'
1434
1440
 
@@ -1469,7 +1475,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1469
1475
  if tracking_mode not in ['deepsort', 'sports2d']:
1470
1476
  logging.warning(f"Tracking mode {tracking_mode} not recognized. Using sports2d method.")
1471
1477
  tracking_mode = 'sports2d'
1472
- logging.info(f'\nPose tracking set up for "{pose_model_name}" model.')
1478
+ logging.info(f'Pose tracking set up for "{pose_model_name}" model.')
1473
1479
  logging.info(f'Mode: {mode}.\n')
1474
1480
  logging.info(f'Persons are detected every {det_frequency} frames and tracked inbetween. Tracking is done with {tracking_mode}.')
1475
1481
  if tracking_mode == 'deepsort': logging.info(f'Deepsort parameters: {deepsort_params}.')
@@ -1526,8 +1532,9 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1526
1532
  if save_angles:
1527
1533
  all_frames_angles.append([])
1528
1534
  continue
1529
- else:
1530
- frames.append(frame.copy())
1535
+ else: # does not store all frames in memory if they are not saved or used for ordering
1536
+ if save_img or save_vid or person_ordering_method == 'on_click':
1537
+ frames.append(frame.copy())
1531
1538
 
1532
1539
  # Retrieve pose or Estimate pose and track people
1533
1540
  if load_trc_px:
@@ -1604,8 +1611,8 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
1604
1611
  # Draw keypoints and skeleton
1605
1612
  if show_realtime_results:
1606
1613
  img = frame.copy()
1607
- cv2.putText(img, f"Press 'q' to quit", (cam_width-int(600*fontSize), cam_height-20), cv2.FONT_HERSHEY_SIMPLEX, fontSize+0.2, (255,255,255), thickness+1, cv2.LINE_AA)
1608
- cv2.putText(img, f"Press 'q' to quit", (cam_width-int(600*fontSize), cam_height-20), cv2.FONT_HERSHEY_SIMPLEX, fontSize+0.2, (0,0,255), thickness, cv2.LINE_AA)
1614
+ cv2.putText(img, f"Press 'q' to stop", (cam_width-int(600*fontSize), cam_height-20), cv2.FONT_HERSHEY_SIMPLEX, fontSize+0.2, (255,255,255), thickness+1, cv2.LINE_AA)
1615
+ cv2.putText(img, f"Press 'q' to stop", (cam_width-int(600*fontSize), cam_height-20), cv2.FONT_HERSHEY_SIMPLEX, fontSize+0.2, (0,0,255), thickness, cv2.LINE_AA)
1609
1616
  img = draw_bounding_box(img, valid_X, valid_Y, colors=colors, fontSize=fontSize, thickness=thickness)
1610
1617
  img = draw_keypts(img, valid_X, valid_Y, valid_scores, cmap_str='RdYlGn')
1611
1618
  img = draw_skel(img, valid_X, valid_Y, pose_model)
@@ -2002,7 +2009,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
2002
2009
  all_frames_angles_processed = all_frames_angles_processed[:,selected_persons,:]
2003
2010
 
2004
2011
  # Reorder keypoints ids
2005
- pose_model_with_new_ids = pose_model
2012
+ pose_model_with_new_ids = copy.deepcopy(pose_model)
2006
2013
  new_id = 0
2007
2014
  for node in PreOrderIter(pose_model_with_new_ids):
2008
2015
  if node.id!=None:
@@ -2020,7 +2027,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
2020
2027
  img = frame.copy()
2021
2028
  img = draw_bounding_box(img, valid_X, valid_Y, colors=colors, fontSize=fontSize, thickness=thickness)
2022
2029
  img = draw_keypts(img, valid_X, valid_Y, valid_scores, cmap_str='RdYlGn')
2023
- img = draw_skel(img, valid_X, valid_Y, pose_model)
2030
+ img = draw_skel(img, valid_X, valid_Y, pose_model_with_new_ids)
2024
2031
  if calculate_angles:
2025
2032
  img = draw_angles(img, valid_X, valid_Y, valid_angles, valid_X_flipped, new_keypoints_ids, new_keypoints_names, angle_names, display_angle_values_on=display_angle_values_on, colors=colors, fontSize=fontSize, thickness=thickness)
2026
2033
 
@@ -2098,7 +2105,6 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
2098
2105
  Pose2Sim_config_dict['project']['participant_mass'] = masses
2099
2106
  Pose2Sim_config_dict['pose']['pose_model'] = pose_model_name.upper()
2100
2107
  Pose2Sim_config_dict = to_dict(Pose2Sim_config_dict)
2101
- print(Pose2Sim_config_dict)
2102
2108
 
2103
2109
  # Marker augmentation
2104
2110
  if use_augmentation:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sports2d
3
- Version: 0.8.1
3
+ Version: 0.8.3
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
  License: BSD 3-Clause License
@@ -122,7 +122,7 @@ https://github.com/user-attachments/assets/6a444474-4df1-4134-af0c-e9746fa433ad
122
122
 
123
123
  `Warning:` Angle estimation is only as good as the pose estimation algorithm, i.e., it is not perfect.\
124
124
  `Warning:` Results are acceptable only if the persons move in the 2D plane (sagittal or frontal plane). The persons need to be filmed as parallel as possible to the motion plane.\
125
- If you need 3D research-grade markerless joint kinematics, consider using several cameras, and constraining angles to a biomechanically accurate model. See **[Pose2Sim](https://github.com/perfanalytics/pose2sim)** for example.
125
+ If you need 3D research-grade markerless joint kinematics, consider using several cameras with **[Pose2Sim](https://github.com/perfanalytics/pose2sim)**.
126
126
 
127
127
  <!--`Warning:` Google Colab does not follow the European GDPR requirements regarding data privacy. [Install locally](#installation) if this matters.-->
128
128
 
@@ -238,7 +238,6 @@ The Demo video is voluntarily challenging to demonstrate the robustness of the p
238
238
  - One person walking in the sagittal plane
239
239
  - One person doing jumping jacks in the frontal plane. This person then performs a flip while being backlit, both of which are challenging for the pose detection algorithm
240
240
  - One tiny person flickering in the background who needs to be ignored
241
- - The first person is starting high and ending low on the image, which messes up the automatic floor angle calculation. You can set it up manually with the parameter `--floor_angle 0`
242
241
 
243
242
  <br>
244
243
 
@@ -509,7 +508,7 @@ sports2d --help
509
508
  'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
510
509
  'to_meters': ["M", "convert pixels to meters. true if not specified"],
511
510
  'make_c3d': ["", "Convert trc to c3d file. true if not specified"],
512
- 'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
511
+ 'floor_angle': ["", "angle of the floor (degrees). 'auto' if not specified"],
513
512
  'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
514
513
  'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
515
514
  'save_calib': ["", "save calibration file. true if not specified"],
@@ -0,0 +1,15 @@
1
+ Sports2D/Sports2D.py,sha256=KWrvWGq49UXta9VJisflyQA-4n7mdu-Uq4GsmDPkaRc,30470
2
+ Sports2D/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
3
+ Sports2D/process.py,sha256=5j36J-G5f9cvoG_1eAPfRoFnPRS8Ipx2YidmY6NR0vQ,107417
4
+ Sports2D/Demo/Config_demo.toml,sha256=GhV-VotYlpYMCu7rHY-AKdWVAT4f61z0oL9-MUBRsOc,13828
5
+ Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
6
+ Sports2D/Utilities/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
7
+ Sports2D/Utilities/common.py,sha256=idMRmesFv5BPX-5g3z5dOVa7SpS_8tNgijvGrOZlR-k,11185
8
+ Sports2D/Utilities/filter.py,sha256=rfZcqofjllKI_5ovZTKEAmyjOZpB_PzbAJ0P874T8Ak,4973
9
+ Sports2D/Utilities/tests.py,sha256=XnPNK63AZ_xlJBmFmPJtOMrzssBXIPXFzYd73CPzchI,4740
10
+ sports2d-0.8.3.dist-info/licenses/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
11
+ sports2d-0.8.3.dist-info/METADATA,sha256=1e4xNUTcZr4_kDn8Ud8Rj83zQ5nIducWD9vXnW6wYGU,39516
12
+ sports2d-0.8.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
13
+ sports2d-0.8.3.dist-info/entry_points.txt,sha256=V8dFDIXatz9VvoGgoHzb2wE71C9-f85K6_OjnEQlxww,108
14
+ sports2d-0.8.3.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
15
+ sports2d-0.8.3.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- Sports2D/Sports2D.py,sha256=0BQ5ainW3EOxElwiXHGywDKVlnHktTIz3EfEH3JhJR0,30460
2
- Sports2D/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
3
- Sports2D/process.py,sha256=UQec7p15gqiuWeHqup6fEtBy2zN06gi39k8Z3zSdfmQ,106805
4
- Sports2D/Demo/Config_demo.toml,sha256=STcdCLpi4-94RpkP6JjvRUxce_QRQnTzjAny71b6ejI,13829
5
- Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
6
- Sports2D/Utilities/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
7
- Sports2D/Utilities/common.py,sha256=idMRmesFv5BPX-5g3z5dOVa7SpS_8tNgijvGrOZlR-k,11185
8
- Sports2D/Utilities/filter.py,sha256=rfZcqofjllKI_5ovZTKEAmyjOZpB_PzbAJ0P874T8Ak,4973
9
- Sports2D/Utilities/tests.py,sha256=XnPNK63AZ_xlJBmFmPJtOMrzssBXIPXFzYd73CPzchI,4740
10
- sports2d-0.8.1.dist-info/licenses/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
11
- sports2d-0.8.1.dist-info/METADATA,sha256=Awdi0qaAyOl1fSOVvMYKGZv-cDXmSAj0k2zTf_QO6GM,39763
12
- sports2d-0.8.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
13
- sports2d-0.8.1.dist-info/entry_points.txt,sha256=V8dFDIXatz9VvoGgoHzb2wE71C9-f85K6_OjnEQlxww,108
14
- sports2d-0.8.1.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
15
- sports2d-0.8.1.dist-info/RECORD,,