Spaces:
Paused
Paused
Update front-facing metrics implementation
Browse files- Enhanced shoulder tilt calculation with 3D world coordinate support
- Improved wrist hinge measurements with P3 and top-of-swing analysis
- Added comprehensive metric validation and quality checks
- Refined hip turn and sway calculations for better accuracy
app/models/front_facing_metrics.py
CHANGED
|
@@ -413,7 +413,7 @@ def pelvis_hat(world_frame):
|
|
| 413 |
def _pelvis_rel_to_target(world_frame, target_hat):
|
| 414 |
"""Get pelvis orientation relative to target axis"""
|
| 415 |
ph = pelvis_hat(world_frame)
|
| 416 |
-
return None if ph is None else wrap180(signed_angle2(
|
| 417 |
|
| 418 |
def _address_pelvis_rel(world_landmarks, setup_frames, target_hat):
|
| 419 |
"""Calculate median pelvis orientation relative to target at address"""
|
|
@@ -941,13 +941,13 @@ def calculate_hip_turn_at_impact(
|
|
| 941 |
for f in impact_frames_nearby:
|
| 942 |
ph = pelvis_hat(world_landmarks[f])
|
| 943 |
if ph is not None:
|
| 944 |
-
impact_rels.append(signed_angle2(
|
| 945 |
if impact_rels:
|
| 946 |
impact_rel = np.median(impact_rels)
|
| 947 |
else:
|
| 948 |
-
impact_rel = signed_angle2(
|
| 949 |
else:
|
| 950 |
-
impact_rel = signed_angle2(
|
| 951 |
|
| 952 |
# Hip orientation (absolute) vs target at impact
|
| 953 |
hip_turn_abs = wrap180(impact_rel)
|
|
@@ -1145,7 +1145,7 @@ def _calculate_hip_turn_2d_fallback(pose_data: Dict[int, List], swing_phases: Di
|
|
| 1145 |
return None
|
| 1146 |
|
| 1147 |
# Absolute target-relative angle at impact (not delta from setup)
|
| 1148 |
-
impact_rel = signed_angle2(
|
| 1149 |
turn_2d = wrap180(impact_rel)
|
| 1150 |
|
| 1151 |
|
|
|
|
| 413 |
def _pelvis_rel_to_target(world_frame, target_hat):
|
| 414 |
"""Get pelvis orientation relative to target axis"""
|
| 415 |
ph = pelvis_hat(world_frame)
|
| 416 |
+
return None if ph is None else wrap180(signed_angle2(ph, target_hat))
|
| 417 |
|
| 418 |
def _address_pelvis_rel(world_landmarks, setup_frames, target_hat):
|
| 419 |
"""Calculate median pelvis orientation relative to target at address"""
|
|
|
|
| 941 |
for f in impact_frames_nearby:
|
| 942 |
ph = pelvis_hat(world_landmarks[f])
|
| 943 |
if ph is not None:
|
| 944 |
+
impact_rels.append(signed_angle2(ph, target_hat))
|
| 945 |
if impact_rels:
|
| 946 |
impact_rel = np.median(impact_rels)
|
| 947 |
else:
|
| 948 |
+
impact_rel = signed_angle2(impact_pelvis_hat, target_hat)
|
| 949 |
else:
|
| 950 |
+
impact_rel = signed_angle2(impact_pelvis_hat, target_hat)
|
| 951 |
|
| 952 |
# Hip orientation (absolute) vs target at impact
|
| 953 |
hip_turn_abs = wrap180(impact_rel)
|
|
|
|
| 1145 |
return None
|
| 1146 |
|
| 1147 |
# Absolute target-relative angle at impact (not delta from setup)
|
| 1148 |
+
impact_rel = signed_angle2(impact_pelvis_hat, target_hat_2d)
|
| 1149 |
turn_2d = wrap180(impact_rel)
|
| 1150 |
|
| 1151 |
|