Repository navigation
fix(examples): resolve camera explicitly in egocentric contact_sheet enrichment - #253
Conversation
…enrichment episode.frames() without a camera raises ValueError when the episode has more than one camera track. contact_sheet was the only step in examples/egocentric/pipeline.py that omitted the camera argument; timestamp_regularity (line 30) and camera_health (line 35) already resolved episode.cameras[0]. Passing camera=episode.cameras[0] makes the example pipeline consistent and fixes the crash on multi-camera recordings. Regression test added in tests/test_enrichments.py verifying that an enrichment resolving the camera explicitly completes without error on a canonical two-camera episode. Fixes Hebbian-Robotics#234
…shows The test defined its own enrichment with the same shape, so reverting the fix in examples/egocentric/pipeline.py left it green. It now loads the real pipeline through import_pipeline_application; reverting either the camera resolution or the new label turns contact_sheet into an ERROR. Adds contact_sheet_camera, which was item 3 of Hebbian-Robotics#234: episode.cameras is sorted, so cameras[0] is alphabetically first rather than the recorder's primary, and a sheet that cannot say which camera it shows is a trap on any multi-camera corpus.
kstonekuan
left a comment
There was a problem hiding this comment.
Merging. The fix is right, and I pushed a fixup on the test because it did not guard what it ships.
Validated on Linux: ruff check, ruff format --check, ty check, 1177 passed, 6 skipped.
Your test defined its own enrichment with the same shape, so it passed either way. I reverted examples/egocentric/pipeline.py back to episode.frames(fps=1.0) and ran your test:
11 passed
Green with the bug back in. The test proved that an enrichment calling frames(camera=..., fps=1.0) works, which was never in doubt; it could not see the file it was shipping alongside. That is the same shape as the python -m hflow test earlier this week, and it is worth naming because it is easy to write by accident: a test that mirrors the fix tests the mirror.
The fixup (082c104) loads the real pipeline through hflow.import_pipeline_application, the same way tests/test_stage_planning.py loads one. monkeypatch.chdir(tmp_path) keeps the example's DATA_ROOT (a relative path) inside the temp directory. Reverting either half of the change now turns contact_sheet into an ERROR:
revert the camera resolution -> 1 failed
drop just the new label -> 1 failed
Item 3 of #234 was missing, so the fixup adds it: contact_sheet_camera in the labels. episode.cameras is sorted, so cameras[0] is the alphabetically first camera rather than the one the recorder considered primary. On this two-camera fixture the sheet renders /top_cam/compressed while the spec declared wrist_cam first. A sheet that cannot say which camera it shows is a trap on any multi-camera corpus, and the assertion on that label is also what makes the test specific.
Thank you for finding this in the first place. It came out of pointing HFlow at real recordings, which keeps producing better material than reading the code does.
Fixes #234
just clearling it out until i come across some other issues which will be fun to work on.
What
contact_sheetinexamples/egocentric/pipeline.pycalledepisode.frames(fps=1.0)without specifying a camera. On episodes withmore than one camera track,
Episode._resolve_camera()raisesValueError: episode has multiple cameras; pass one explicitly.timestamp_regularity(line 30) andcamera_health(line 35) in thesame file already resolved
episode.cameras[0]. This change makescontact_sheetconsistent with them.Validation