Skip to content

Commit 0843f11

Browse files
committed
more validation in extr
1 parent a981a8c commit 0843f11

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

fiftyone/core/dataset.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,12 +1322,13 @@ def _validate_sensor_extrinsics(self, extrinsics):
13221322
f"but got source_frame='{value.source_frame}'"
13231323
)
13241324

1325-
if value.target_frame is not None:
1326-
if value.target_frame != expected_target:
1327-
raise ValueError(
1328-
f"Key '{key}' expects target_frame='{expected_target}' "
1329-
f"but got target_frame='{value.target_frame}'"
1330-
)
1325+
# Treat target_frame=None as "world" for comparison
1326+
actual_target = value.target_frame or "world"
1327+
if actual_target != expected_target:
1328+
raise ValueError(
1329+
f"Key '{key}' expects target_frame='{expected_target}' "
1330+
f"but got target_frame='{value.target_frame}'"
1331+
)
13311332

13321333
def resolve_intrinsics(self, sample):
13331334
"""Resolves camera intrinsics for the given sample.

tests/unittests/camera_tests.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,19 +1969,20 @@ def test_sensor_extrinsics_multiple_valid(self):
19691969

19701970
@drop_datasets
19711971
def test_sensor_extrinsics_partial_fields_source_only(self):
1972-
"""Test validation with only source_frame set (target_frame can be None)."""
1972+
"""Test validation with only source_frame set (target_frame=None implies world)."""
19731973
dataset = fo.Dataset()
19741974

1975-
# source_frame matches (required), target_frame is None (optional)
1975+
# source_frame matches (required), target_frame is None (implies "world")
19761976
extrinsics = SensorExtrinsics(
19771977
translation=[1.5, 0.0, 1.2],
19781978
quaternion=[0.0, 0.0, 0.0, 1.0],
19791979
source_frame="camera_front",
1980-
# target_frame is None
1980+
# target_frame is None, which is treated as "world"
19811981
)
19821982

1983-
dataset.sensor_extrinsics = {"camera_front::ego": extrinsics}
1984-
self.assertIn("camera_front::ego", dataset.sensor_extrinsics)
1983+
# Key uses implied "world" target (no ::target suffix)
1984+
dataset.sensor_extrinsics = {"camera_front": extrinsics}
1985+
self.assertIn("camera_front", dataset.sensor_extrinsics)
19851986

19861987
def test_sensor_extrinsics_partial_fields_target_only_raises(self):
19871988
"""Test that missing source_frame raises ValueError at construction even if target_frame is set."""

0 commit comments

Comments
 (0)