Spaces:
Running
Running
Return full interval telemetry
Browse files
app.py
CHANGED
|
@@ -465,6 +465,37 @@ def results(session_id: UUID, request: Request):
|
|
| 465 |
continue
|
| 466 |
analytics = report.get("analytics") or {}
|
| 467 |
metrics = [{"name": key.replace("_", " ").title(), "value": value, "unit": ""} for key, value in analytics.items() if isinstance(value, (int, float, str, bool)) or value is None]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
clips = [{"cameraId": camera_id,
|
| 469 |
"url": f"/storage/{session_id}/videos/{filename}",
|
| 470 |
"poster": f"/storage/{session_id}/posters/camera_{camera_id}.webp"}
|
|
@@ -478,7 +509,7 @@ def results(session_id: UUID, request: Request):
|
|
| 478 |
"preFrames": 0, "inFrame": max(0, (end - start) // 2), "postFrames": 0,
|
| 479 |
"cameraClips": clips, "sourceCameraClips": [], "preMetrics": [],
|
| 480 |
"preActionMetrics": [], "inActionMetrics": metrics, "postMetrics": [],
|
| 481 |
-
"postActionMetrics": [], "fullIntervalMetrics":
|
| 482 |
"skeleton": report.get("skeleton_history", []), "rawAnalytics": analytics})
|
| 483 |
created = row.get("created_at")
|
| 484 |
created_at = datetime.fromisoformat(created.replace("Z", "+00:00")) if created else datetime.now(timezone.utc)
|
|
|
|
| 465 |
continue
|
| 466 |
analytics = report.get("analytics") or {}
|
| 467 |
metrics = [{"name": key.replace("_", " ").title(), "value": value, "unit": ""} for key, value in analytics.items() if isinstance(value, (int, float, str, bool)) or value is None]
|
| 468 |
+
full_interval = report.get("full_interval") or {}
|
| 469 |
+
telemetry_names = {
|
| 470 |
+
"head_angle": ("Head Angle", "°"),
|
| 471 |
+
"trunk_lean": ("Trunk Lean", "°"),
|
| 472 |
+
"left_knee_angle": ("Left Knee Angle", "°"),
|
| 473 |
+
"right_knee_angle": ("Right Knee Angle", "°"),
|
| 474 |
+
"active_ball_dist": ("Active Foot to Ball Distance", "cm"),
|
| 475 |
+
"ball_speed": ("Ball Speed", "cm/s"),
|
| 476 |
+
"active_heel_speed": ("Active Heel Speed", "cm/s"),
|
| 477 |
+
"feet_distance": ("Feet Distance", "cm"),
|
| 478 |
+
"left_heel_height": ("Left Heel Height", "cm"),
|
| 479 |
+
"right_heel_height": ("Right Heel Height", "cm"),
|
| 480 |
+
}
|
| 481 |
+
full_interval_metrics = []
|
| 482 |
+
metric_frames = {}
|
| 483 |
+
for frame_text, frame_data in full_interval.items():
|
| 484 |
+
if not isinstance(frame_data, dict):
|
| 485 |
+
continue
|
| 486 |
+
try:
|
| 487 |
+
frame_number = int(frame_text) - start
|
| 488 |
+
except (TypeError, ValueError):
|
| 489 |
+
continue
|
| 490 |
+
if frame_number < 0 or frame_number >= max(0, end - start + 1):
|
| 491 |
+
continue
|
| 492 |
+
for key, (metric_name, unit) in telemetry_names.items():
|
| 493 |
+
value = frame_data.get(key)
|
| 494 |
+
if isinstance(value, (int, float)) and math.isfinite(value):
|
| 495 |
+
metric_frames.setdefault(key, []).append({"frame": frame_number, "value": value})
|
| 496 |
+
for key, values in metric_frames.items():
|
| 497 |
+
if values:
|
| 498 |
+
full_interval_metrics.append({"name": telemetry_names[key][0], "unit": telemetry_names[key][1], "values": values})
|
| 499 |
clips = [{"cameraId": camera_id,
|
| 500 |
"url": f"/storage/{session_id}/videos/{filename}",
|
| 501 |
"poster": f"/storage/{session_id}/posters/camera_{camera_id}.webp"}
|
|
|
|
| 509 |
"preFrames": 0, "inFrame": max(0, (end - start) // 2), "postFrames": 0,
|
| 510 |
"cameraClips": clips, "sourceCameraClips": [], "preMetrics": [],
|
| 511 |
"preActionMetrics": [], "inActionMetrics": metrics, "postMetrics": [],
|
| 512 |
+
"postActionMetrics": [], "fullIntervalMetrics": full_interval_metrics,
|
| 513 |
"skeleton": report.get("skeleton_history", []), "rawAnalytics": analytics})
|
| 514 |
created = row.get("created_at")
|
| 515 |
created_at = datetime.fromisoformat(created.replace("Z", "+00:00")) if created else datetime.now(timezone.utc)
|