Skip to content

Architecture

Browser (React, TypeScript, three.js)        Python (FastAPI)                  pyCGM2 environment
┌────────────────────────────────┐   HTTP   ┌──────────────────────────┐  JSON  ┌──────────────────────┐
│ 3D view, timeline, graphs,     │ ───────► │ server/   routes, session│ lines  │ bridges/pycgm2/      │
│ marker list, panels            │ ◄─────── │ core/     state, commands│ ─────► │  worker.py           │
│ zustand store: a mirror of the │  binary  │ io/       C3D (ezc3d)    │ C3D    │  btk_compat.py       │
│ session, typed arrays          │  arrays  │ labeling/ auto-labeling  │ files  │ (pyCGM2, OpenSim)    │
└────────────────────────────────┘          │ gapfill/ filters events  │        └──────────────────────┘
                                            │ forceplates cli          │
                                            └──────────────────────────┘
  • The backend owns the state. The server holds the open trials, their labels and the undo history. The interface and the command line send the same commands (core/commands.py), and the server answers with small changes. Point data travel once, as binary arrays.
  • Tracklets are the unit of labeling: one continuous run of one trajectory. A label is constant within a tracklet and appears at most once per frame; range edits split tracklets first. Every command records what it changed, so undo is exact and replaying a log gives exactly the same labels.
  • Edit logs (core/project.py) hold the source file's SHA-256 and the commands, as JSON lines next to the trial.
  • C3D input and output (io/c3d_io.py) go through ezc3d, keeping every parameter, analog channel and event, and the unknown groups untouched.
  • Auto-labeling (labeling/): statics are fitted to a marker-set template (rigid clusters of markers, several poses and headings, Hungarian assignment); walking trials follow the subject's static, tracklet by tracklet, leaving doubtful samples unlabeled.
  • The pyCGM2 bridge runs pyCGM2 in its own process and Python environment. worker.py speaks JSON lines over stdin and stdout and exchanges data as C3D files. It runs with Python 3.9+ and the standard library only, and gives pyCGM2 btk_compat.py, BTK's interface over ezc3d, so BTK is not needed. OpenMotionLabel itself never imports pyCGM2.
  • The interface is built with Vite into src/openmotionlabel/web/ and shipped inside the Python wheel, so installing needs no Node.js.