Skip to content

Add FreeMoCap sidecar contract and client integration#75

Open
rupertgermann wants to merge 1 commit into
mainfrom
codex/real-freemocap-sidecar
Open

Add FreeMoCap sidecar contract and client integration#75
rupertgermann wants to merge 1 commit into
mainfrom
codex/real-freemocap-sidecar

Conversation

@rupertgermann

Copy link
Copy Markdown
Owner

Summary

  • Add a documented contract for the FreeMoCap sidecar and local setup guidance
  • Introduce the Python sidecar package with CLI, server, sources, and contract handling
  • Wire the web app to connect to the sidecar for mocap sessions and pose streaming
  • Add tests covering the sidecar contract, package install flow, and pose source integration

Testing

  • Added and updated unit/integration tests for the sidecar contract and client flows
  • Validated the new sidecar pose source behavior with targeted test coverage
  • Not run (not requested)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 030af5c5a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +164 to +166
key = self.headers.get("Sec-WebSocket-Key")
if self.headers.get("Upgrade", "").lower() != "websocket" or not key:
self._send_json(HTTPStatus.BAD_REQUEST, {"error": "Expected WebSocket upgrade"})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict sidecar origins before exposing pose frames

When the sidecar is running, any webpage the user visits can open ws://localhost:<port>/pose-stream because the WebSocket upgrade accepts requests solely based on the upgrade key, and the HTTP endpoints also advertise Access-Control-Allow-Origin: *. In that scenario a malicious site can start/stop the local session endpoints and read live 3D body keypoints from localhost, bypassing the app's consent/privacy controls; the sidecar should reject unexpected Origin values (for both HTTP CORS and WebSocket upgrades) before streaming frames.

Useful? React with 👍 / 👎.

Comment on lines +218 to +219
tracked = sum(1 for confidence in confidences if confidence >= 0.5)
mean_confidence = sum(confidences) / len(confidences)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit FreeMoCap quality to rowing landmarks

When a recorded FreeMoCap file has the rowing-relevant joints tracked but low-confidence unused landmarks such as face or hand points, these lines compute both tracked_count and mean_confidence across all 33 keypoints. The app turns meanConfidence < 0.6 or trackedCount < 13 into LOW_CONFIDENCE, so valid rowing data can be flagged degraded, while high-confidence unused landmarks can also mask missing knees or ankles. Compute these fields over the 13 rowing landmarks defined by the contract.

Useful? React with 👍 / 👎.

Comment on lines +187 to +188
frame = self.sidecar_state.source.frame(frame_index, timestamp_ms)
_send_websocket_text(self.request, json.dumps(frame, separators=(",", ":")))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject non-finite pose values before streaming JSON

When recorded .npy or JSON data contains NaN/Infinity for missed landmarks, the source preserves those floats and this json.dumps call emits non-standard JSON tokens such as NaN. The browser client uses JSON.parse for WebSocket messages, so the first such frame is reported as a parse failure and the sidecar capture errors out; validate or sanitize non-finite coordinates/confidences before reporting the source ready or stream with strict JSON handling.

Useful? React with 👍 / 👎.

Comment on lines +303 to +304
ordered = sorted(keypoints, key=lambda item: int(item["index"]))
return [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate JSON keypoint indexes before remapping

When recorded JSON/JSONL data contains ADR-style keypoint objects with a duplicate, missing, or out-of-range index, this loader sorts by the provided index but then drops it; frame() later re-enumerates the list as indexes 0–32. That makes malformed input report ready while silently assigning coordinates to the wrong BlazePose landmarks, corrupting the stored skeleton and posture analysis instead of failing readiness.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant