Skip to content

Commit d088ace

Browse files
committed
lower likelihood threshold for floor line and small docstring edits
1 parent 62984f4 commit d088ace

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Sports2D/Utilities/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737

3838
## CONSTANTS
39+
# 4 points joint angle: between knee and ankle, and toe and heel. Add 90° offset and multiply by 1
40+
# 3 points joint angle: between ankle, knee, hip. -180° offset, multiply by -1
41+
# 2 points segment angle: between horizontal and ankle and knee, 0° offset, multiply by -1
3942
angle_dict = { # lowercase!
4043
# joint angles
4144
'right ankle': [['RKnee', 'RAnkle', 'RBigToe', 'RHeel'], 'dorsiflexion', 90, 1],

Sports2D/process.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ def on_ok(event):
12771277
return selected_persons
12781278

12791279

1280-
def compute_floor_line(trc_data, score_data, keypoint_names = ['LBigToe', 'RBigToe'], toe_speed_below = 7, score_threshold=0.5):
1280+
def compute_floor_line(trc_data, score_data, keypoint_names = ['LBigToe', 'RBigToe'], toe_speed_below = 7, score_threshold=0.3):
12811281
'''
12821282
Compute the floor line equation, angle, and direction
12831283
from the feet keypoints when they have zero speed.
@@ -1327,7 +1327,7 @@ def compute_floor_line(trc_data, score_data, keypoint_names = ['LBigToe', 'RBigT
13271327

13281328
# Fit a line to the zero-speed coordinates
13291329
floor_line = np.polyfit(low_speeds_X, low_speeds_Y, 1) # (slope, intercept)
1330-
angle = -np.arctan(floor_line[0]) # angle of the floor line in degrees
1330+
angle = -np.arctan(floor_line[0]) # angle of the floor line in radians
13311331
xy_origin = [0, floor_line[1]] # origin of the floor line
13321332

13331333
# Gait direction
@@ -2383,9 +2383,9 @@ def get_correction_message(xy_origin):
23832383
if visible_side_i == 'auto':
23842384
try:
23852385
if all(key in trc_data[i] for key in ['LBigToe', 'RBigToe']):
2386-
_, _, gait_direction = compute_floor_line(trc_data[i], score_data[i], keypoint_names=['LBigToe', 'RBigToe'], score_threshold=average_likelihood_threshold) # toe_speed_below=1 bu default
2386+
_, _, gait_direction = compute_floor_line(trc_data[i], score_data[i], keypoint_names=['LBigToe', 'RBigToe'], score_threshold=keypoint_likelihood_threshold) # toe_speed_below=1 bu default
23872387
else:
2388-
_, _, gait_direction = compute_floor_line(trc_data[i], score_data[i], keypoint_names=['LAnkle', 'RAnkle'], score_threshold=average_likelihood_threshold)
2388+
_, _, gait_direction = compute_floor_line(trc_data[i], score_data[i], keypoint_names=['LAnkle', 'RAnkle'], score_threshold=keypoint_likelihood_threshold)
23892389
logging.warning(f'The RBigToe and LBigToe are missing from your model. Gait direction will be determined from the ankle points.')
23902390
visible_side_i = 'right' if gait_direction > 0.3 \
23912391
else 'left' if gait_direction < -0.3 \
@@ -2695,7 +2695,7 @@ def get_correction_message(xy_origin):
26952695
if (mot_file.parent/(mot_file.stem+'_ik.mot')).exists():
26962696
os.remove(mot_file.parent/(mot_file.stem+'_ik.mot'))
26972697
os.rename(mot_file, mot_file.parent/(mot_file.stem+'_ik.mot'))
2698-
logging.info(f'.osim model and .mot motion file results saved to {kinematics_dir.resolve()}.\n')
2698+
logging.info(f'.osim model and .mot motion file results saved to {kinematics_dir.resolve().parent}.\n')
26992699

27002700
# Move all files in pose-3d and kinematics to the output_dir
27012701
osim.Logger.removeFileSink()

0 commit comments

Comments
 (0)