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
19 changes: 19 additions & 0 deletions examples/egocap/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,22 @@ before any file is written. An existing derived episode is refused, never replac
rewriting `config.yaml`, and never record into a session that has none.
- Work that must survive a cancelled caller (notifying the aligner of a kept episode, for one) runs inside the
owned operation task, not after the awaited result.
- A label of a recorded session (task, studio) is not corrected while the session holds a take that is still to
be filed by, or into, what is being corrected: an unsettled take with a studio in its manifest and no
assignment yet, or one whose assignment names the group being corrected. The recorder files a kept take by the
labels its manifest froze. Never loosen `assign_output`'s check, and never write a manifest from a correction.
A correction holds the recorder's own session lock for its checks and its writes, and one that really changes
a routed group's studio or whole task drops the session's route to the group.
- Whether a recorder has a session open, and which of its takes wait, have one definition each, the recorder's:
`OutputScan.held_closed` (through the coordinator's `hold_closed_session`) and `takes_left_behind`. Anything
that writes into a closed session asks them, and holds the session with `SessionHold`, never `SessionLock`:
only a recorder writes a beat.
- A line or a refusal shown to an operator carries no path and nothing a parser, the interpreter or the system
said; `scan_session` is the one reader of a session's take records.
- A correction of a session's studio or task that answers with a failure leaves the labels as they were, or
names the ones it could not put back, and says so from what the disk holds.
- A required device is judged on whether it delivers its data, from the capture session's own reason for its
state; a degraded reason nobody has read yet holds recording.
- Leaving the video room is guarded on every way out: the room is left in a `finally`, and what the leave raises
is logged and fails neither a take nor a shutdown.
- Read a session's studio through `egocap.studio.session_studio`, not from the name of its folder.
288 changes: 285 additions & 3 deletions examples/egocap/CALIBRATION_TOOLS.md

Large diffs are not rendered by default.

64 changes: 53 additions & 11 deletions examples/egocap/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ CaptureServer, serves the browser, and writes recorded sessions to local storage

A station belongs to one operator working at a time. A site usually has several, so the stations
are kept by the backend and chosen from the page: each has a name, a camera type, the camera that
fills each role (the operator's view and each wrist), and the capture host address last given to
its headset. The station in use names every recording and its activity log. A deployment's station
fills each role (the operator's view and each wrist), the tracking devices it requires, and the
capture host address last given to its headset. The station in use names every recording and its activity log. A deployment's station
file still supplies the initial task instruction, the default operator name, the recording output
location, the cameras requested from CaptureServer, and the station label used while no station has
been set up. At startup, the backend reads the station's camera names and
Expand All @@ -45,9 +45,20 @@ every tracking device and camera, the calibration files of its cameras, and room
disk. Nothing is run; the checklist is judged continuously. With a station in use a take is refused,
with the reason, while any item fails; a device or check the station does not use is skipped. An
item fails for what would stop a take anyway (capture not running, no tracking data, a camera with
no frames) and for a full disk. What goes beyond that only warns: a device reporting another state
than connected, and missing calibration files, which are optional unless the deployment requires
them (an operator setting, off by default). With no stations set up the checklist only advises.
no frames), for a full disk, and for a tracking device the station requires (its headset, a
controller or a glove, chosen per station) that is not connected: switched off, not found, not
started yet, not reported, or switched off in the capture configuration. A required device must be
delivering its data: one that is connected with nothing to send holds recording, and one that still
delivers with a problem of its own, such as a rejected calibration file, only warns. A requirement
fails closed: one the software does not know, as a newer version may have written it, is kept and
holds recording until it is removed, and stations that were saved and cannot be read hold recording
until they are replaced. A calibration take is held only by the devices its tool uses. What goes beyond that only warns:
a device the station does not require reporting another state than connected, and missing
calibration files, which are optional unless the deployment requires them (an operator setting, off
by default). A station requires no device until it is told to. A camera whose video arrives
over LiveKit passes only while an operator's page reports its frames arriving in the preview, since
the backend joins that video only for the length of a take or of a live check of the head calibration
that an operator starts; anything else the page reports of it warns with what to check. With no stations set up the checklist only advises.

Before recording, the operator also selects or enters the task being demonstrated, and confirms the
live preview — camera video and tracked pose — looks correct. Starting an episode requires every required source to be
Expand All @@ -74,12 +85,27 @@ The report shows the station's active and down time with its blockers and the op
can be saved on the station. A dataset-reporting library function also counts each station's valid
versus excluded episodes from the saved session metadata, for offline use.

A misfiled task can be corrected from the report for one take or a range of a session's takes. Only
labels change; recorded video and tracking stay as captured, and a session is never moved from the
page. A correction is refused for the session still open for recording, while a take of that session
is being time-aligned or another correction of it is being written, and for anything that is not a
recorded session inside the recording output. A library function, for offline use, relocates an
older session saved under the wrong studio.
A misfiled task can be corrected from the report for one take or a range of a session's takes, and
the studio a whole session is labelled with can be corrected there too. Only labels change; recorded
video and tracking stay as captured, and a session is never moved: a corrected studio is written into
the recording's own metadata, and a session that lies in a folder named after the studio it was
recorded under stays in that folder. The report and the dataset counts read the studio from the
session's metadata, so they show the corrected one; a file browser shows the folder as it is. A
correction of either label is refused for a session open for recording, in this backend or in any
other recorder on the same output, while a take of that session is being time-aligned or another
correction of it is being written, while the session holds a take that was interrupted and is still
to be filed by, or into, what is being corrected (the recorder files such a take by the labels it
was recorded under), and for anything that is not a recorded session inside the recording output.
Whether a recorder has the session open, and which takes wait, are judged by the recorder's own
rules, the ones that list a waiting take with its two commands: the refusal over such a take names
that list, the correction holds the session without marking it as a recorder does, and the take can
be recovered or discarded right after.
Either correction is all or nothing: it is checked whole before its first write, a write that still
fails puts back what was written, and a correction that answers with a failure either left the
session as it was or says, from what the disk holds, which labels it could not put back. A group
whose studio or whole task was really changed stops receiving later takes of its session, which
claim a fresh group. A library function,
for offline use, relocates an older session saved under the wrong studio.

### Timing and calibration requirements

Expand Down Expand Up @@ -357,6 +383,22 @@ every file need the control token, which the page exchanges once for a same-site
request a browser marks as coming from another site is refused. It is independent of
the recording page: it never reconnects to CaptureServer and never affects a live session.

### Not yet verified on hardware

What this document says of the following has been exercised against the mock capture server, scripted stand-ins
and synthetic data only:

- A station requiring its tracking devices: which path and type a real headset, controller and glove report under,
how quickly each leaves the connected state when it is switched off or loses tracking, and the degraded and
switched-off states, which the mock never reports: which of them still deliver data was read from the capture
session's own code, not seen from a device.
- The live check's verdict: the camera offset and lag it finds were seen on rendered scenes only, and the noise
of a real headset's tracking, which decides how soon the views pin them, is unmeasured.
- A LiveKit camera passing only while its frames are seen in the preview: no LiveKit server or camera sender was
run.
- The corrections and the rules that hold them: run on sessions a real recording service wrote with one numeric
source, never on a session with recorded video, and never with two backends on one output.

## 4. Assumptions and scope

This design serves a single operator working at one station at a time. The browser, backend, and
Expand Down
81 changes: 79 additions & 2 deletions examples/egocap/LIVEKIT_PREVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,65 @@ uv run uvicorn egocap_web.app:app --app-dir backend --port 8000
requests (data messages on topic `isaaccapture.clock-sync`) and reading its replies. The publisher must stay
in the room and answer them; without replies the mapping goes stale.

## Checked before a take

The backend is in the room only while a take records or a live check of the head calibration runs (see "Joined
for a calibration check" below), so at other times it receives nothing from a LiveKit camera. The page is in the
room all the time, to show the picture. A page that holds the control token and is in
view therefore tells the backend, every two seconds, what its preview receives of each stream
(`POST /api/setup/livekit-preview`), and the station checklist goes by the best report under six seconds old:

| What a page reports | The camera's item | What it says |
| --- | --- | --- |
| frames are arriving | passes | `frames are arriving in the preview` |
| the track is subscribed and no frame has come for three seconds | warns | `no frames in the preview: check the camera and its sender; the recorder checks this camera itself when a take starts` |
| the sender has not published the track | warns | `its sender is not publishing it: start the camera sender; the recorder checks this camera itself when a take starts` |
| the page could not join the room | warns | `the preview cannot join the video room; the recorder checks this camera itself when a take starts` |
| nothing (no page with the token is in view) | warns | `not checked here: keep this page in view with the control token entered; the recorder checks this camera itself when a take starts` |

A stream that cannot be recorded at all still fails, as before. A report never fails the item and never holds a
take, and the page says so: a warning is listed as "Advisory: does not hold recording.", the Devices step reads
"takes are not held", and each sentence above names the recorder as what checks next. A report is one browser's
observation, and a browser can fail to receive video the recorder would receive (another network path, a codec
the browser lacks). What refuses a take is the recorder itself, which joins the room when the take starts and
gives up, with its reason, when a stream sends no frame within ten seconds.

A check of the backend's own would need one of two things, and neither is built:

- The backend staying in the room between takes: the recorder's receiver joined for as long as the session offers
the streams, with a take attaching to that connection. This is a second subscriber to every camera for the whole
day (the server forwards each stream once more, and counting frames without decoding them needs the receiver to
read transport statistics instead of pictures), plus a reconnect policy the take-length connection does not need.
- Asking the LiveKit server, through its room service API, whether the publisher is in the room and publishes the
track. That carries no media, and needs the server's HTTP API reachable from the backend and a token with the
room-administration grant. It says the track is published, not that frames flow.

## Joined for a calibration check

The calibration tool's *Check the installed calibration* (see
[`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#checking-the-installed-calibration-live)) needs live pictures of
the head camera on the head poses' clock. When that camera is a LiveKit stream, the backend joins the room for
the length of the check: one more viewer, of that one camera's track, with a viewer's token of its own
(`LIVEKIT_API_KEY` and `LIVEKIT_API_SECRET`, as for recording). It is the recorder's own source
(`LiveKitRecordingSource`) told of one stream, so the join, the first-frame and size check, the clock-sync
exchange and the placing of each frame's time are a take's, and so are the conditions: a monotonic
`timestamp_basis`, `width`, `height` and `fps` in the streams file, a publisher that answers clock-sync requests,
and CaptureServer on the same computer. Nothing is recorded.

The backend leaves the room when the check is stopped, when no page has asked about it for 20 seconds, when a
take starts (the check ends first; a check is refused while a take records), when its video fails, when the
check has run for ten minutes, and at shutdown. This is an operator's explicit action for a bounded time; it is
not the standing connection the checklist does without, and between checks and takes the backend is still not
in the room.

Leaving is guarded. The frame receiver disconnects from the room whatever an earlier step of its leave raised,
and the recorder's source leaves the room whatever stopping its feed raised; both hold for a take as well. What
a check's leave raises is logged and fails neither the take that is starting, the stop from the page nor the
shutdown. A take waits at most two seconds for the check to be out of the room: the two join under identities
of their own, so a leave the room is slow to answer finishes behind the take. A way into the room that fails is
said to the operator in one fixed sentence per stage; what the video library or the video server answered goes
to the backend's log only, since a server's error body can hold anything.

## Corrected video

A LiveKit stream is recorded as it is published. When the publisher is the camera bridge started by
Expand All @@ -117,11 +176,29 @@ streams file, and tells the backend what it applied through `EGOCAP_STREAMS_STAT
calibration tools refuse to calibrate a lens from that video. See
[`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#rectification).

The backend holds no picture of a LiveKit camera outside a take: the page shows the stream itself. While a
calibration take records, the calibration tools' live guide looks at the frames the recorder is fed for the take,
The backend holds no picture of a LiveKit camera outside a take and a calibration check: the page shows the
stream itself. While a calibration take records, the calibration tools' live guide looks at the frames the recorder is fed for the take,
so such a camera is guided from the take's first frame on (see
[`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#live-guidance)).

A backend started by hand, as in step 4, is told nothing about the streams and takes every one for uncorrected: its
sessions carry no `rectification.json`. Publish corrected video to it only when that is understood; recording
corrected video is what the launcher is for.

## Not yet verified on hardware

- The page's reports have been exercised against a scripted room and a scripted video element, and the checklist
against scripted reports. No LiveKit server, camera sender or emulator was run by this work, so a pass has not
been seen for a real stream.
- How long a browser takes to present the first frame of a real stream, against the three seconds after which a
subscribed track is called silent.
- Whether a browser tab that is in view but covered by another window keeps presenting frames; a tab the browser
reports hidden sends no report.
- The room join for a calibration check was run against the recorder's test stand-in for the frame receiver only,
never against a real room or publisher. Whether a second viewer from the backend beside the operator's page
changes what the page receives, and how a LiveKit picture's mapped time and a tracking sample's time lie
relative to one another on a real station, are unmeasured.
- Whether the real LiveKit library's leave returns promptly and never raises is not known: every way out of the
room depends on it, the stand-in's leave is instant and silent, and the guards around it (a `finally` in the
receiver and in the source, a limit of 1.5 seconds on the check's leave) were exercised with injected faults
and a stand-in that stalls, not with a real room.
Loading
Loading