sports2d 0.8.5__py3-none-any.whl → 0.8.7__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/Demo/Config_demo.toml +1 -0
- Sports2D/Sports2D.py +3 -1
- Sports2D/process.py +35 -11
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/METADATA +3 -2
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/RECORD +9 -9
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/WHEEL +0 -0
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/entry_points.txt +0 -0
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/licenses/LICENSE +0 -0
- {sports2d-0.8.5.dist-info → sports2d-0.8.7.dist-info}/top_level.txt +0 -0
Sports2D/Demo/Config_demo.toml
CHANGED
|
@@ -151,6 +151,7 @@ filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
|
|
|
151
151
|
[kinematics]
|
|
152
152
|
do_ik = false # Do scaling and inverse kinematics?
|
|
153
153
|
use_augmentation = false # true or false (lowercase) # Set to true if you want to use the model with augmented markers
|
|
154
|
+
feet_on_floor = false # true or false (lowercase) # Set to false if you want to use the model with feet not on the floor (e.g. running, jumping, etc.)
|
|
154
155
|
use_contacts_muscles = true # true or false (lowercase) # If true, contact spheres and muscles are added to the model
|
|
155
156
|
participant_mass = [55.0, 67.0] # kg # defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)
|
|
156
157
|
right_left_symmetry = true # true or false (lowercase) # Set to false only if you have good reasons to think the participant is not symmetrical (e.g. prosthetic limb)
|
Sports2D/Sports2D.py
CHANGED
|
@@ -205,6 +205,7 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
205
205
|
},
|
|
206
206
|
'kinematics':{'do_ik': False,
|
|
207
207
|
'use_augmentation': False,
|
|
208
|
+
'feet_on_floor': False,
|
|
208
209
|
'use_contacts_muscles': True,
|
|
209
210
|
'participant_mass': [55.0, 67.0],
|
|
210
211
|
'right_left_symmetry': True,
|
|
@@ -244,7 +245,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
244
245
|
'calculate_angles': ["c", "calculate joint and segment angles. true if not specified"],
|
|
245
246
|
'save_angles': ["A", "save angles as mot files. true if not specified"],
|
|
246
247
|
'slowmo_factor': ["", "slow-motion factor. For a video recorded at 240 fps and exported to 30 fps, it would be 240/30 = 8. 1 if not specified"],
|
|
247
|
-
'pose_model': ["p", "
|
|
248
|
+
'pose_model': ["p", "body_with_feet, whole_body_wrist, whole_body, or body. body_with_feet if not specified"],
|
|
248
249
|
'mode': ["m", 'light, balanced, performance, or a """{dictionary within triple quote}""". balanced if not specified. Use a dictionary to specify your own detection and/or pose estimation models (more about in the documentation).'],
|
|
249
250
|
'det_frequency': ["f", "run person detection only every N frames, and inbetween track previously detected bounding boxes. keypoint detection is still run on all frames.\n\
|
|
250
251
|
Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate. 1 if not specified: detection runs on all frames"],
|
|
@@ -258,6 +259,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
258
259
|
'save_calib': ["", "save calibration file. true if not specified"],
|
|
259
260
|
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
260
261
|
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
262
|
+
'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
|
|
261
263
|
'use_contacts_muscles': ["", "Use model with contact spheres and muscles. false if not specified"],
|
|
262
264
|
'participant_mass': ["", "mass of the participant in kg or none. Defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)"],
|
|
263
265
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
Sports2D/process.py
CHANGED
|
@@ -66,6 +66,7 @@ import itertools as it
|
|
|
66
66
|
from tqdm import tqdm
|
|
67
67
|
from collections import defaultdict
|
|
68
68
|
from anytree import RenderTree
|
|
69
|
+
from anytree.importer import DictImporter
|
|
69
70
|
|
|
70
71
|
import numpy as np
|
|
71
72
|
import pandas as pd
|
|
@@ -986,7 +987,6 @@ def select_persons_on_vid(frames, all_pose_coords):
|
|
|
986
987
|
bbox=dict(facecolor=UNSELECTED_COLOR, edgecolor=LINE_UNSELECTED_COLOR, boxstyle='square,pad=0.3', path_effects=[patheffects.withSimplePatchShadow()]), zorder=3
|
|
987
988
|
)
|
|
988
989
|
rects.append(rect)
|
|
989
|
-
annotations.append(annotation)
|
|
990
990
|
img_plot = ax_video.imshow(frame_rgb)
|
|
991
991
|
|
|
992
992
|
# Slider
|
|
@@ -1043,6 +1043,10 @@ def select_persons_on_vid(frames, all_pose_coords):
|
|
|
1043
1043
|
bbox=dict(facecolor=UNSELECTED_COLOR, edgecolor=LINE_UNSELECTED_COLOR, boxstyle='square,pad=0.3'), path_effects=[patheffects.withSimplePatchShadow()], zorder=3
|
|
1044
1044
|
)
|
|
1045
1045
|
annotations.append(annotation)
|
|
1046
|
+
else:
|
|
1047
|
+
rect = plt.Rectangle((np.nan, np.nan), np.nan, np.nan)
|
|
1048
|
+
ax_video.add_patch(rect)
|
|
1049
|
+
rects.append(rect)
|
|
1046
1050
|
|
|
1047
1051
|
# Update plot
|
|
1048
1052
|
img_plot.set_data(frame_rgb)
|
|
@@ -1377,6 +1381,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
1377
1381
|
use_augmentation = config_dict.get('kinematics').get('use_augmentation')
|
|
1378
1382
|
participant_masses = config_dict.get('kinematics').get('participant_mass')
|
|
1379
1383
|
participant_masses = participant_masses if isinstance(participant_masses, list) else [participant_masses]
|
|
1384
|
+
feet_on_floor = config_dict.get('kinematics').get('feet_on_floor')
|
|
1380
1385
|
fastest_frames_to_remove_percent = config_dict.get('kinematics').get('fastest_frames_to_remove_percent')
|
|
1381
1386
|
large_hip_knee_angles = config_dict.get('kinematics').get('large_hip_knee_angles')
|
|
1382
1387
|
trimmed_extrema_percent = config_dict.get('kinematics').get('trimmed_extrema_percent')
|
|
@@ -1423,15 +1428,12 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
1423
1428
|
cv2.setWindowProperty(f'{video_file} Sports2D', cv2.WND_PROP_ASPECT_RATIO, cv2.WINDOW_FULLSCREEN)
|
|
1424
1429
|
|
|
1425
1430
|
# Select the appropriate model based on the model_type
|
|
1431
|
+
logging.info('\nEstimating pose...')
|
|
1426
1432
|
if pose_model.upper() in ('HALPE_26', 'BODY_WITH_FEET'):
|
|
1427
1433
|
model_name = 'HALPE_26'
|
|
1428
1434
|
ModelClass = BodyWithFeet # 26 keypoints(halpe26)
|
|
1429
1435
|
logging.info(f"Using HALPE_26 model (body and feet) for pose estimation.")
|
|
1430
|
-
elif pose_model.upper()
|
|
1431
|
-
model_name = 'COCO_133_WRIST'
|
|
1432
|
-
ModelClass = Wholebody
|
|
1433
|
-
logging.info(f"Using COCO_133 model (body, feet, 2 hand points) for pose estimation.")
|
|
1434
|
-
elif pose_model.upper() in ('COCO_133', 'WHOLE_BODY'):
|
|
1436
|
+
elif pose_model.upper() in ('COCO_133', 'WHOLE_BODY', 'WHOLE_BODY_WRIST'):
|
|
1435
1437
|
model_name = 'COCO_133'
|
|
1436
1438
|
ModelClass = Wholebody
|
|
1437
1439
|
logging.info(f"Using COCO_133 model (body, feet, hands, and face) for pose estimation.")
|
|
@@ -1439,10 +1441,32 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
1439
1441
|
model_name = 'COCO_17'
|
|
1440
1442
|
ModelClass = Body
|
|
1441
1443
|
logging.info(f"Using COCO_17 model (body) for pose estimation.")
|
|
1444
|
+
elif pose_model.upper() =='HAND':
|
|
1445
|
+
model_name = 'HAND_21'
|
|
1446
|
+
ModelClass = Hand
|
|
1447
|
+
logging.info(f"Using HAND_21 model for pose estimation.")
|
|
1448
|
+
elif pose_model.upper() =='FACE':
|
|
1449
|
+
model_name = 'FACE_106'
|
|
1450
|
+
logging.info(f"Using FACE_106 model for pose estimation.")
|
|
1451
|
+
elif pose_model.upper() =='ANIMAL':
|
|
1452
|
+
model_name = 'ANIMAL2D_17'
|
|
1453
|
+
logging.info(f"Using ANIMAL2D_17 model for pose estimation.")
|
|
1442
1454
|
else:
|
|
1443
|
-
|
|
1455
|
+
model_name = pose_model.upper()
|
|
1456
|
+
logging.info(f"Using model {model_name} for pose estimation.")
|
|
1444
1457
|
pose_model_name = pose_model
|
|
1445
|
-
|
|
1458
|
+
try:
|
|
1459
|
+
pose_model = eval(model_name)
|
|
1460
|
+
except:
|
|
1461
|
+
try: # from Config.toml
|
|
1462
|
+
pose_model = DictImporter().import_(config_dict.get('pose').get(pose_model))
|
|
1463
|
+
if pose_model.id == 'None':
|
|
1464
|
+
pose_model.id = None
|
|
1465
|
+
except:
|
|
1466
|
+
raise NameError(f'{pose_model} not found in skeletons.py nor in Config.toml')
|
|
1467
|
+
|
|
1468
|
+
# Select device and backend
|
|
1469
|
+
backend, device = setup_backend_device(backend=backend, device=device)
|
|
1446
1470
|
|
|
1447
1471
|
# Manually select the models if mode is a dictionary rather than 'lightweight', 'balanced', or 'performance'
|
|
1448
1472
|
if not mode in ['lightweight', 'balanced', 'performance']:
|
|
@@ -2124,7 +2148,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
2124
2148
|
|
|
2125
2149
|
# Delete person if less than 4 valid frames
|
|
2126
2150
|
pose_path_person = pose_output_path.parent / (pose_output_path.stem + f'_person{i:02d}.trc')
|
|
2127
|
-
all_frames_X_person = pd.DataFrame(all_frames_X_homog[:,i,:], columns=
|
|
2151
|
+
all_frames_X_person = pd.DataFrame(all_frames_X_homog[:,i,:], columns=new_keypoints_names)
|
|
2128
2152
|
pose_nan_count = len(np.where(all_frames_X_person.sum(axis=1)==0)[0])
|
|
2129
2153
|
if frame_count - frame_range[0] - pose_nan_count <= 4:
|
|
2130
2154
|
# heights_m.append(DEFAULT_HEIGHT)
|
|
@@ -2147,8 +2171,8 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
|
|
|
2147
2171
|
|
|
2148
2172
|
Pose2Sim_config_dict['project']['participant_height'] = heights_m
|
|
2149
2173
|
Pose2Sim_config_dict['project']['participant_mass'] = masses
|
|
2150
|
-
Pose2Sim_config_dict['project']['frame_range'] =
|
|
2151
|
-
Pose2Sim_config_dict['markerAugmentation']['feet_on_floor'] =
|
|
2174
|
+
Pose2Sim_config_dict['project']['frame_range'] = 'all'
|
|
2175
|
+
Pose2Sim_config_dict['markerAugmentation']['feet_on_floor'] = feet_on_floor
|
|
2152
2176
|
Pose2Sim_config_dict['pose']['pose_model'] = pose_model_name.upper()
|
|
2153
2177
|
Pose2Sim_config_dict = to_dict(Pose2Sim_config_dict)
|
|
2154
2178
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sports2d
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.7
|
|
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>
|
|
@@ -473,7 +473,7 @@ sports2d --help
|
|
|
473
473
|
'calculate_angles': ["c", "calculate joint and segment angles. true if not specified"],
|
|
474
474
|
'save_angles': ["A", "save angles as mot files. true if not specified"],
|
|
475
475
|
'slowmo_factor': ["", "slow-motion factor. For a video recorded at 240 fps and exported to 30 fps, it would be 240/30 = 8. 1 if not specified"],
|
|
476
|
-
'pose_model': ["p", "
|
|
476
|
+
'pose_model': ["p", "body_with_feet, whole_body_wrist, whole_body, or body. body_with_feet if not specified"],
|
|
477
477
|
'mode': ["m", 'light, balanced, performance, or a """{dictionary within triple quote}""". balanced if not specified. Use a dictionary to specify your own detection and/or pose estimation models (more about in the documentation).'],
|
|
478
478
|
'det_frequency': ["f", "run person detection only every N frames, and inbetween track previously detected bounding boxes. keypoint detection is still run on all frames.\n\
|
|
479
479
|
Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate. 1 if not specified: detection runs on all frames"],
|
|
@@ -487,6 +487,7 @@ sports2d --help
|
|
|
487
487
|
'save_calib': ["", "save calibration file. true if not specified"],
|
|
488
488
|
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
489
489
|
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
490
|
+
'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
|
|
490
491
|
'use_contacts_muscles': ["", "Use model with contact spheres and muscles. false if not specified"],
|
|
491
492
|
'participant_mass': ["", "mass of the participant in kg or none. Defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)"],
|
|
492
493
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
|
@@ -9,18 +9,18 @@ Content/paper.md,sha256=8rWSOLrKTysloZv0Fz2lr3nayxtHi7GlFMqwdgDVggY,11333
|
|
|
9
9
|
Content/sports2d_blender.gif,sha256=wgMuPRxhja3XtQn76_okGXsNnUT9Thp0pnD36GdW5_E,448786
|
|
10
10
|
Content/sports2d_opensim.gif,sha256=XP1AcjqhbGcJknXUoNJjPWAwaM9ahZafbDgLWvzKJs4,376656
|
|
11
11
|
Sports2D/Sports2D.ipynb,sha256=VnOVjIl6ndnCJTT13L4W5qTw4T-TQDF3jt3-wxnXDqM,2427047
|
|
12
|
-
Sports2D/Sports2D.py,sha256=
|
|
12
|
+
Sports2D/Sports2D.py,sha256=dalsLajzjMxhf8A26OSLHGD8az_deheW9u9CsDVb7fk,30792
|
|
13
13
|
Sports2D/__init__.py,sha256=BuUkPEdItxlkeqz4dmoiPwZLkgAfABJK3KWQ1ujTGwE,153
|
|
14
|
-
Sports2D/process.py,sha256=
|
|
15
|
-
Sports2D/Demo/Config_demo.toml,sha256=
|
|
14
|
+
Sports2D/process.py,sha256=qmeIhQIEmdpsBEWdjsJJzC_lc6DF11iM8yl0wzHHl_g,110565
|
|
15
|
+
Sports2D/Demo/Config_demo.toml,sha256=S6QTErGIdUvCB3HoBFqlZKtQmbUU-c2cQYJJSW3HXUk,14003
|
|
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=XnPNK63AZ_xlJBmFmPJtOMrzssBXIPXFzYd73CPzchI,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.7.dist-info/licenses/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
|
|
22
|
+
sports2d-0.8.7.dist-info/METADATA,sha256=VM20oIZDLU_zQLlnZpjFlNTIU31VLiHIoYv9rsGOyuc,38245
|
|
23
|
+
sports2d-0.8.7.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
24
|
+
sports2d-0.8.7.dist-info/entry_points.txt,sha256=V8dFDIXatz9VvoGgoHzb2wE71C9-f85K6_OjnEQlxww,108
|
|
25
|
+
sports2d-0.8.7.dist-info/top_level.txt,sha256=cWWBiDD2WbQXMoIoN6-9et9U2t2c_ZKo2JtBqO5uN-k,17
|
|
26
|
+
sports2d-0.8.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|