Repository navigation
egocap: judge each take when it ends, set bad takes aside, recover or discard from the page - #1638
NVshawnhwang wants to merge 4 commits into
Conversation
…e camera The camera adapter asked its latest-frame queue once per frame interval. When that cadence fell in step with the camera's, a poll that came a moment before a frame found nothing and the frame was never made up: on a device the size-one queue is then overwritten, and the mock passes the frame over. A 30 fps camera recorded 22 to 27 fps this way. Ask the queue several times per frame interval, so a frame waits at most a fraction of an interval and the next cannot arrive before it is taken. Everything defined on the frame interval stays on it: the no-frame timeout still counts from the last frame, and the host-sampling time is still taken at the poll that returned the frame. An empty poll returns nothing, as before, and callers already skip it. Tests drive the real adapter against the mock queue with its frame grid in step with the poll clock and with polls that wake early and late, and against a one-slot queue that overwrites as a device's does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Shawn Hwang <shhwang@nvidia.com>
… discard from the page Capture checks - Each take is judged once, after it stops, by checks whose limits come from a documented defaults file and the station's own data_check section. A camera that averaged under the minimum share of its declared rate, or recorded under that share of the frames a take of that length holds, rejects the take and removes its media. A tracking stream that does not change for longer than the limit marks the take bad. Tracking gaps, take length and the other checks warn. - A take too short to measure is not judged by the rate rule. - A take marked bad is kept and not time-aligned. With the station's quarantine switch on, which is the default, it is finalized under the quarantine folder, apart from its session, and counted on its own. - A take can be started exempt from the checks by a server-side flag that no command from the page can set. Takes that wait - An interrupted take can be recovered or discarded from the page, in the open session and in earlier sessions of the station. A discard records its intent before it removes anything, and removes only the take's own pending directory. - A session another recorder has open is told by its lock, and where a lock does not reach by a marker the recorder refreshes every second, and nothing in it is listed or acted on. - Stopping the recorder before any file-changing call of a start, a keep, a rejection, a quarantine or a discard leaves a take that recover or discard resolves. What the operator is told - Every outcome and refusal is a fixed sentence that names the stream, what was measured, the limit and what to check. No reply carries a path, an exception's text or a recorder state name. A full, read-only or unwritable recordings disk is named. - The page shows what became of each take above the cameras, never shows an outcome it does not know as kept, asks before a discard in a dialog of its own, counts each kind in the end-of-day summary, and shows the checks in force, with a notice when a station runs with one switched off or loosened. The mock capture server gains a camera fault that withholds frames for the manual run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Shawn Hwang <shhwang@nvidia.com>
The calibration tools and the capture checks were built apart. Joined, a calibration take (a board waved at one camera, hands held still) is what the checks reject for its camera's rate or set aside for tracking that does not change. Every take the headset calibration tool and the controller-glove offset tool start is therefore started with the recorder's exemption flag: it is checked for storage integrity only and kept unjudged, and its manifest and metadata say so. The flag is the calibration service's own. No field of a request is read for it, and a take started with Record is always judged. What the tools read of the recorder is what the recording page is told: - What became of a take is read from the page's own description of it (take_outcome.describe_result). A take is saved only when that says kept; any other outcome is told with the page's sentences, whole ones only. A take the integrity check rejects is said to keep its data until it is discarded on the recording page, which lists it. - An interrupted calibration take waits in the page's list like any other and is recovered or discarded there. The tools say so, where they sent the operator to a new batch. One that is recovered is finished exempt, as it was started. - A refusal of the recorder at a take's start or end is answered with the sentence a refused recording command gets (recording_command.refusal_sentence), readiness is asked as Record asks it, and a full recordings disk is named. What the coordinator or the recording service raised stays in the log. Found by running the two pieces together: - The configuration that only looks at what earlier sessions left is built every few seconds, during a take too. It wrote the session files of a run that corrects a camera again at each build, so a copy found missing held recording in the middle of a take and interrupted it. That configuration names those files without writing them. - A take left waiting by a run that corrected no camera is listed in a run that corrects one, and neither command resolves it there: its session does not hold the files that run requires, and a session is reopened only as it was recorded. A test pins it, and the guide and the README say to resolve such a take in a run started without the correction. - The camera adapter asks for a frame sooner after it starts, so a camera's first picture can arrive before the first tracking sample. The tests of the real application wait for both before a take. The tools' guide, the READMEs and the design say that calibration takes are exempt, where they said the checks judge them like any other take. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Shawn Hwang <shhwang@nvidia.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
🤖 Agent-generated (Claude Code · claude-sonnet-5-5) Summary This stacks three commits: a poll-cadence fix in the DepthAI camera adapter, per-take capture checks with a quarantine folder and Recover/Discard of interrupted takes (in the open session and in earlier ones), and an exemption of the calibration tools' takes from the checks. The file-moving code is careful: every destructive step is preceded by a durable manifest write, ownership is stamped and re-verified before any rename or delete, and the stamp is removed last so an interrupted delete can be repeated. I found no path that deletes outside the judged take's own pending directory. The adapter fix is sound in logic, but the 22 to 27 fps figure is a mock artefact and is not evidence about a device. My concerns are about what changes for existing stations without opting in, one irreversible default (media removal on a camera rate rule that has never seen a real camera), and scope: this is several features in one review. I read the source and docs of the whole diff and the adapter tests; I did not run anything (the example's uv environment does not resolve in a scratch worktree here, so the cadence tests were not executed). Legend: 🚫 Blocker · 💡 Suggestion · 🔍 Nit
On the frame-skip fix (commit 1). The reasoning is correct for a device queue of size one that is refilled on the device's own clock: with one poll per interval, any poll gap longer than one interval (the sleep that ends late, followed by one that ends on time) lets two frames arrive between polls, and the first is overwritten. Four polls per interval need a wake-up that is three poll periods late to lose a frame. The tests ( On the capture-check rules. The thresholds match what the native recording path uses: a camera average of at least 0.86 of its rate, a pose still for 1 s at 1e-6 flagging the take, the same pose fields (head and controller poses, glove hands), advisory drops, flat motion and dead streams. The differences from the native path I checked in the code: it judges only the head and two wrist cameras (this PR judges every camera); it counts a camera with fewer than two frames as 0 fps and rejects it, where this PR says "not judged" for a take too short to measure; it treats a dead glove hand as fatal by default (see the finding above); and its coverage, time-range overlap and consecutive-gap timestamp checks are advisory there and are not carried over here. The rate rule applied to short takes (under ten frame intervals of camera span) is now skipped, which is the sensible fix for the "one frame moves the average" problem. The tolerance constant On state-machine and file-moving safety. I traced Questions for the author
Actionables (for bots — copy-paste-ready for AI)
|
NVdejung
left a comment
There was a problem hiding this comment.
🤖 Automated first-pass review (Claude, for Dejun) — I'll follow up personally where needed.
Summary — Stacked on #1637, this PR does three things. The DepthAI adapter now polls four times per frame interval. Every take is judged when it stops, by a file-driven policy: a camera rate/coverage rule that removes media, freeze/gap/length gates, and a _quarantine/ folder, with calibration takes exempt. Interrupted or left-behind takes, including earlier sessions' takes found by a beat-aware output scan, can be recovered or discarded from the page. The file-moving code is careful: ownership is checked before every rename or delete, the intent is recorded first and the stamp removed last. I found no path that deletes outside a take's own pending directory. Two blockers remain, one of them already raised. I read all non-test source and docs. I only skimmed the ~60 test files and styles.css, and I ran nothing.
Must fix
- Still open from the earlier review: capture checks are on by default for every station and remove media on a camera rule that has not yet been measured on a real camera (
capture_qc_policy.py:57,data_check_config.yaml:24). I won't repeat that review here. I agree it should be settled before merge: either ship the rule off (or log-only) until a station's cameras are measured, or get an explicit sign-off from the stations' owners. - Two places call
OutputScan.note_closed()synchronously on the event loop:recording_session.py:1035(New batch) andrecording_session.py:881(after every Recover/Discard of an earlier take).- It takes
_guard(output_scan.py:180), whichread()holds in a worker thread for its whole walk of the output (output_scan.py:115). The loop then stops until the read in flight ends, and with it the preview, every viewer's socket and the CaptureServer client. - The wait is short in steady state. But the first read after a start, or after the station's names change, is a full one: about half a minute per ~12k take records by the README's own figure.
note_closed()also reads the lock file on the loop.- Fix:
await asyncio.to_thread(self._output_scan.note_closed, …), asjudge()already is. Alternatively, hold_guardonly around the state updates, not the I/O.
- It takes
Suggestions
recording_session.py:1038,:883: New batch and Recover/Discard of an earlier takeawait refresh_pending()inside the owned operation. They queue behind any read in flight (same durations as above), and Record is refused meanwhile. The page gives New batch 45 s. Please verify on a large folder. Scheduling the refresh, or setting a dirty flag, would avoid the wait.app.py:386: withgloves_expected: true,manus_gloveis a required source for every take. The exemption only skips the capture checks (recording_service.py:1296). So a head- or wrist-camera calibration take with no glove rows failsrequired_sources_nonemptyand is rejected with its data kept. Meanwhile the guide'stracking_recorded, which looks at headset and controllers only, reads ready. Either exempt calibration takes from the glove requirement, or say so in the hints andCALIBRATION_TOOLS.md. No test covers this case.recording_command.py:124: the operator's sentence is chosen by matching substrings of exception text raised in other modules. The same applies to_PENDING_REFUSALS,take_outcome._NOTE_KINDSandlivekit_recording._START_REFUSALS. A rewordedraisesilently falls back to the generic sentence. Broad markers ("already has a","a recording session (","calibration asset") can match the wrong one. Exception subclasses or acodeattribute would be safer.recording_command.py:754: everyConfigurationErrorraised while reopening an earlier session is answered with "its source declarations or calibration files have changed". That includes an invalid QC policy (the factory raisesQC_CONFIG_INVALID) and a session folder that no longer exists.capture_qc.py:783: stale docstring.TRACKING_GATESnow includestracking_gap, so withtracking_gap_marks_bada gap writes the nativefreeze_check_passed = False.day_report.py:257: a session whose files raiseOSErroris now dropped silently.backend/README.md:237still says an unreadable record "is reported with its session, never dropped".takeOutcomeText.ts:50: after an earlier session's take is resolved, the banner says "Take N …" without naming the session. That is easy to read as take N of the current batch.- CI: no workflow runs
examples/egocap/tests, and the recording-service README says those tests are local-only. With deletion on by default, the self-containedtests/recording_serviceandtests/recordingsuites are worth wiring into CI. - Internal names: the scan found one hit (
test_take_outcome.py:407). It is a private-range IP address in a fixture that checks raw error text never reaches the page. It reads as a generic placeholder, so it is not a must-fix. A documentation-range address would make that obvious. I found nothing else in the added fixtures or docs.
Conflicts
- With
nvShawnHwang/egocap_calibration_page(head of#1637): 0 commits behind and the local 3-way merge is clean, so no rebase is needed. The PR sits mid-stack above#1634–#1637; retarget it tomainonce those land. - Stack children by the same author:
#1639(based on this branch, 41 shared files) and#1640–#1646. No textual conflicts were found, but each will need restacking after changes here. Check#1644(upload) against_quarantine/, schema-5 manifests and theQUARANTINEDphase. #1586(gareth-morgan-nv, basemain, 14 shared files includingapp.py,recording_session.py,recording_command.pyanduseCaptureSession.ts): conflicts were not computed because the base differs. Expect textual conflicts, since the snapshot parser moved torecordingSnapshotParser.ts. There is also a semantic risk: any new coordinator refusal there falls back to the generic sentence unless it is added to_COMMAND_REFUSALS. Whichever PR lands second rebases.#1625(Yunjuliii, draft) sharesrecording_adapter.py.MANUS_POSE_STREAMSpicks up every 4×4 field ofMANUS_GLOVE_SPEC, so a 4×4 field added there becomes a judged stream on glove stations.#1566,#1571,#1587and#1591each share one README or test file; low risk.
Change-by-change (130 files)
| File / area | What changed | Makes sense? |
|---|---|---|
capture_server/.../depthai.py, mock/mock_depthai.py, test_camera_poll_cadence.py, test_mock_sdks.py |
Poll 4× per frame interval (timeout still in frame intervals); mock camera_stall fault |
✅ empty polls are not counted anywhere (server.py skips them) |
recording/egocap/recording/capture_qc.py, capture_measure.py |
Two-question camera rule (frames_needed), switchable gap/duration gates, new advisories (zero pose, fps deviation, resolution, rate-measurable), ALGORITHM_VERSION 4, quarantine finalization |
✅ quality_attributes docstring |
capture_qc_policy.py, config/data_check/data_check_config.yaml, pyproject.toml |
Defaults file is now read and shipped as package data; strict key/type/range validation; station data_check overrides; capture_config_for |
✅ fails closed on a bad file |
episode_layout.py, route.py, episode_store.py |
Schema 5, QUARANTINED phase and stamped _quarantine/<session> claim, discard_requested, misplaced records, session beat in SessionLock, naming_the_file |
✅ ownership checked before each rename/delete |
recording_service/recording_service.py, output_scan.py, models.py, __init__.py, README |
Quarantine finalize, exempt takes, retained integrity rejections, discard intent, storage_problem, beat notes, pending_under_output_root with OutputScan |
✅ _guard held across the whole read (must-fix 2) |
backend/egocap_web/recording_session.py |
Earlier-session listing and resolution through a second service, PendingTake, beat-stopped readiness, exempt flag |
|
recording_command.py, take_outcome.py, readiness_text.py, livekit_recording.py |
Fixed operator sentences for outcomes, refusals and notes; per-outcome counts; pending_takes; recover_pending/discard_pending |
✅ no raw text reaches the page |
app.py, settings_routes.py, station_config.py, recording_adapter.py |
QC policy load (holds Record when invalid), scan config factory, station names, 5 s refresh; quality_checks with notices in settings |
✅ |
calibration_service.py, calibration_common.py; comment-only edits in rectification_service.py, CalibrationRecorder.tsx, GloveOffsetDialog.tsx, HeadsetCalibrationDialog.tsx |
Calibration takes started exempt; outcome read via describe_result; refusals via refusal_sentence |
✅ location matches the old take_name() form |
auto_align.py |
Takes marked bad are not aligned (submit and scan) | ✅ |
station_service.py, station_uptime.py |
A rename is recorded for any station; all_names() follows renames across days |
✅ (a name given up and retaken belongs to both; documented) |
day_report.py, day_report_routes.py, count_daily_trajectories.py |
quarantined disposition; reasons and warnings via describe_manifest; quarantined takes excluded from valid time |
✅ |
Frontend model: recordingSnapshotParser.ts (moved out of useCaptureSession.ts), recordingTypes.ts, recordingEligibility.ts, recordingUiReducer.ts, recordingWire.ts, recordingActions.ts |
Per-row/per-outcome tolerant parsing; resolvePending eligibility; a reply whose snapshot cannot be read settles as unknown |
✅ |
Frontend UI: TakeOutcomeBanner, PendingTakeActions, PendingTakesCard, DiscardTakeDialog, RecordingPanel, OperatorBar, WrapUpDialog, App, SettingsPanel, outcomeMarks, takeOutcomeText, formatElapsed, dayReportApi, settingsApi, settingsParts, styles.css |
Outcome banner above the cameras, pending rows with Recover/Discard and one confirm, not-kept counts, Capture checks card | ✅ hooks before early returns, Discard asks once |
Docs: README.md, DESIGN.md, CALIBRATION_TOOLS.md, backend/README.md, frontend/README.md, recording/README.md, recording_service/README.md, ego_stations.example.yaml |
Capture checks, quarantine, pending takes, exact limits, what is unverified on hardware | ✅ thorough |
| Tests (~60 files, ~12k lines; skimmed) | New suites: QC rules, policy, quarantine, removal scope, stop-at-every-step, takes left behind, wire, frontend | ✅ edited tests were updated, not weakened (e.g. test_capture_qc.py fixture lengthened to 3 s, test_configuration.py drops the "quarantine unsupported" case) |
Reviewed at 468e42a · 130 files · 2026-12-01 13:30 PST
…/egocap_quality_control The recording coordinator takes both sides' arguments. A take the capture checks set apart in quarantine is given the capture-session facts like a kept one, which the textual merge had left out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Shawn Hwang <shhwang@nvidia.com>
Branch:
nvShawnHwang/egocap_quality_control, opened againstnvShawnHwang/egocap_calibration_page.Commits in this pull request:
egocap: do not skip camera frames when the poll falls in step with the cameraegocap: judge each take when it ends, set bad takes aside, recover or discard from the pageegocap: calibration takes are exempt from the capture checksSummary
Three commits.
egocap: do not skip camera frames when the poll falls in step with the camera— a capture fix that stands onits own. The adapter for directly connected cameras asked its latest-frame queue once per frame interval, so a
frame that arrived a moment after a poll was never made up; a 30 fps camera recorded 22 to 27 fps against the
mock. It now asks several times per interval. Without this fix the rate rule below rejects healthy takes.
the take and removes its media;
with the station's quarantine switch on (the default) finalized under a quarantine folder apart from its session;
An interrupted take can be recovered or discarded from the page, in the open session and in earlier sessions
of the station. Every outcome and refusal is a fixed sentence that names the stream, what was measured, the limit
and what to check.
What to know before relying on it
has a table of how late a healthy camera would have to start to lose a take, says how a station switches the rule
off or loosens it in its own file, and the Settings view shows a notice when it is off or loosened.
told by its lock, and where a lock does not reach by a marker the recorder refreshes every second. A recorder that
is frozen or whose disk stalls for a few seconds can look closed to another machine. No network share was tested.
recorded; and, unchanged by this pull request, a backend shut down while a take is being recorded.
page can set. The third commit makes the calibration tools' takes use it.
How it was tested
tests/recordingat 100% line and branch coverage;tests/recording_service;tests/capture_server;tests/backend; the page's lint, tests and build.each kind of discard (533 points): every take is then resolved by Recover or Discard, and nothing outside the
take's own directory changes.
crashes, races, anything the page can send). Nothing was deleted outside the judged take's own pending directory.
tests/recording/unit/test_video_writer_backends.py::test_release_raises_when_ffmpeg_does_not_exit_after_stdin_closes.Not yet verified on hardware
The rate a real camera records at on either path (direct or LiveKit); real tracking when it stops or rests; real
gloves; a camera unplugged during a take; a shared recordings folder on a network; power loss.
🤖 Generated with Claude Code