Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 62 additions & 9 deletions examples/egocap/recording/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ SPDX-License-Identifier: Apache-2.0

# recording

The recording module library: configuration I/O, episode storage/layout, video writers, QC and
studio/task-library lookups. A Python module library, not a runnable application — nothing here
is launched, it's imported, by the recording service (`recording_service/`) and the backend. See
the root [`README.md`](../README.md) for install, and [`../DESIGN.md`](../DESIGN.md) for how
this fits into the overall architecture.
The recording module library: configuration I/O, episode storage/layout, video writers, QC,
station calibration and studio/task-library lookups. A Python module library, not a runnable
application — nothing here is launched, it's imported, by the recording service
(`recording_service/`) and the backend. See the root [`README.md`](../README.md) for install, and
[`../DESIGN.md`](../DESIGN.md) for how this fits into the overall architecture.

This package never opens a physical camera or reads a device SDK directly — a camera is a JPEG
byte stream and tracking is a sample, both arriving over CaptureServer's own WebSocket protocol
Expand Down Expand Up @@ -49,6 +49,8 @@ Calibration copying is best-effort either way: a file simply absent at that loca
with a warning, recording still proceeds. Calibration files are optional unless the deployment
requires them: the web backend holds a station in use from recording over a missing file only while
its operator setting `require_calibration` is on (see [`backend/README.md`](../backend/README.md)).
The files are made and installed by the calibration tools
(see [`../CALIBRATION_TOOLS.md`](../CALIBRATION_TOOLS.md)).

`video_sources`/`numeric_sources` declare the *recorded dataset*, not how to open a device — no
device handle, index, or launcher path belongs in them. See
Expand Down Expand Up @@ -79,7 +81,32 @@ actually having data to work with. Provisioning real/fixture CSVs is a deploymen

`episode_store.py`'s `EpisodeStore` owns per-episode Zarr/MP4 storage: appending numeric rows
and video frames, and the dataset-level `studio`/Mid-Train `inverse`/`props` zarr attrs. Images
are recorded as received, with no rectification applied.
are stored as they are received; nothing in this package corrects one. What is received need not be
what the lens delivered: a camera that reaches the station through the camera bridge is recorded as
the bridge publishes it, which is corrected (rectified) when the launcher applied the station's
rectification plan to its stream. A session recorded in such a run says so in its files: the
corrected camera's intrinsics file describes the recorded, corrected pictures, the lens they were
corrected from is kept beside it under a lens name, and `rectification.json` names the corrected
cameras with everything that was done. A rectified copy of a take can also be written offline,
outside the recording, by `tools/calibrate_station.py rectify`. See
[`../CALIBRATION_TOOLS.md`](../CALIBRATION_TOOLS.md#what-is-recorded).

`aligned_writer.py` writes the time-aligned copy of a kept episode into a session of its own. It
pairs each picture with the tracking of the moment the picture shows: when the head-camera
extrinsics file the session carries states the camera's lag (`camera_latency_s`, found by the
headset calibration), that lag is taken off the times of every camera of the episode before
anything is paired, moved by what the recorder's tracking latency has changed by since the lag was
measured when the file states that too. An aligned episode that had a lag taken off records it in
its `camera_lag` attribute: `taken_off_s`, the `cameras` it came off, the `source` file and the
values it was made from (`camera_latency_s`, `tracking_latency_s`, `take_tracking_latency_s`). Its
`valid_timestamps` are then the index frames' recorded times less `taken_off_s`, the moments the
pictures show on the tracking's time base, while each camera's own `capture_time` stays as
recorded. An episode without the attribute was aligned on its recorded times: its session had no
such file, or one that states no usable lag or was not made with this project's tracking. An
episode whose session states a lag for a stated tracking latency, while the take does not say which
latency it was recorded under, is refused. The session's calibration files, the lens files and
`rectification.json` among them, are carried into the aligned session as they are. See
[`../CALIBRATION_TOOLS.md`](../CALIBRATION_TOOLS.md#camera-lag-in-aligned-takes).

`episode_layout.py` owns the on-disk layout: pending/final directory naming, studio/timestamp
routing (`assign_output`/`finalize_episode_dir` route each finalized episode to
Expand All @@ -94,6 +121,18 @@ rest of the package's atomic writes build on.
failure to `<session_root>/errors.jsonl` — a tail-able, greppable record independent of the Zarr
store.

## Calibration — `egocap/calibration/`

Camera intrinsics under OpenCV's radial-tangential (`pinhole`) or `fisheye` lens model, the head
camera's position on the headset, the controller-to-glove wrist offset, and installing the results
into the station's calibration directory; the rule for a stored camera lag, which the glove tool
and the time aligner share; and rectification: the gates on a calibration, the plan of a corrected
picture from an explicit geometry and oversample, the remap table file the camera bridge's GPU step
loads, and the offline corrected copy of a take. The backend's calibration tools,
`tools/calibrate_station.py` and the launcher (`../tools/start_system.py`) are built on it. What each
module does, the limits it applies and how an operator uses the tools are in
[`../CALIBRATION_TOOLS.md`](../CALIBRATION_TOOLS.md).

## Analytics — `egocap/analytics/`

- `station_status_log.py`'s `StationStatusTracker` is a per-station, per-day active/inactive
Expand Down Expand Up @@ -142,6 +181,9 @@ What the recording service writes into each routed group:
│ ├── head_camera_intrinsics.json, head_camera_extrinsics.json
│ ├── left_wrist_camera_intrinsics.json, right_wrist_camera_intrinsics.json
│ ├── wrist_calibration_offsets.json
│ ├── rectification.json # only when the run corrected a camera's video
│ ├── head_camera_lens_intrinsics.json # only for a camera whose video was corrected;
│ │ # likewise left_wrist_... and right_wrist_camera_lens_intrinsics.json
│ ├── episode_0/, episode_1/, ...
│ └── ...
└── _unmatched/ # descriptions matching no known studio
Expand All @@ -150,7 +192,11 @@ What the recording service writes into each routed group:

Calibration files appear only when present at `EGOCAP_CALIBRATION_DIR` (which always has a
resolved value, see above -- absence there is a skip, not a configuration requirement); the
service does not write a separate `data_check_config.yaml`.
service does not write a separate `data_check_config.yaml`. In a run whose capture stack corrects a
camera's video the web backend supplies required assets for it: `rectification.json`, the
corrected camera under the role's intrinsics file name, and the station's lens file under the
role's lens name. A session is not opened without them, and a session that has no
`rectification.json` holds no corrected video.

The per-group `config.yaml` carries the source declarations time alignment reads (the
`video_sources`/`numeric_sources` names, frame types and recording defaults); a data-loading
Expand Down Expand Up @@ -186,6 +232,13 @@ hardware (see `capture_server/README.md`'s "implemented but not exercised on har

Calibration assets are copied into every session under their established filenames when
available: head camera intrinsics and extrinsics, left/right wrist camera intrinsics (wrist
cameras have no separate extrinsics file), and the wrist-to-hand `wrist_calibration_offsets.json`;
cameras have no separate extrinsics file), and the controller-to-glove wrist offsets,
`wrist_calibration_offsets.json`;
a session recorded without calibration present still produces valid video/tracking data, just
without those sidecar files.
without those sidecar files. A session's intrinsics file describes the video the session holds. For
a camera recorded as received that is the station's lens calibration. For a camera listed in the
session's `rectification.json` the recorded pictures are corrected ones, and the session's
intrinsics file for that role is the corrected camera, a pinhole camera without distortion; the
lens the pictures were corrected from is in the role's lens file
(`head_camera_lens_intrinsics.json`, `left_wrist_camera_lens_intrinsics.json`,
`right_wrist_camera_lens_intrinsics.json`), which does not describe the recorded pictures.
5 changes: 5 additions & 0 deletions examples/egocap/recording/egocap/calibration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

"""Station calibration: camera intrinsics, head-camera extrinsics, controller-to-glove offsets, rectification."""
Loading
Loading