2727_OSDAR26_SENSOR_PATTERN = re .compile (r"^rgb_\d+mp_(left|middle|right)$|^ir_(left|middle|right)$" )
2828
2929
30- def _uses_osdar26_calibration ( sensor_id : str ) -> bool :
31- """Detect if the sensor uses OSDAR26 calibration conventions.
30+ def _scene_uses_osdar26_calibration ( scene : raillabel . Scene ) -> bool :
31+ """Detect if the scene uses OSDAR26 calibration conventions.
3232
3333 OSDAR26 sensors have different extrinsics rotation axis conventions
34- compared to OSDAR23. This function detects the calibration type based on
35- sensor naming patterns.
34+ compared to OSDAR23. This function checks ALL sensors in the scene and
35+ determines the calibration type based on naming patterns.
36+
37+ A scene is considered OSDAR26 if ANY of its sensors match the OSDAR26
38+ naming pattern. This is more robust than checking individual sensors,
39+ as a scene is either entirely OSDAR23 or entirely OSDAR26.
3640
3741 Parameters
3842 ----------
39- sensor_id : str
40- The sensor identifier to check.
43+ scene : raillabel.Scene
44+ The scene to check.
4145
4246 Returns
4347 -------
4448 bool
45- True if the sensor uses OSDAR26 calibration conventions.
49+ True if the scene uses OSDAR26 calibration conventions.
4650 """
47- return bool (_OSDAR26_SENSOR_PATTERN .match (sensor_id ))
51+ for sensor_id in scene .sensors :
52+ if _OSDAR26_SENSOR_PATTERN .match (sensor_id ):
53+ return True
54+ return False
4855
4956
5057def validate_horizon (scene : raillabel .Scene ) -> list [Issue ]:
5158 """Validate whether all track/transition annotations are below the horizon.
5259
5360 The horizon validation automatically detects the calibration format based on
5461 sensor naming conventions and applies the appropriate coordinate transformation.
62+ The detection is done once per scene by checking all sensor names.
5563
5664 Parameters
5765 ----------
@@ -66,6 +74,9 @@ def validate_horizon(scene: raillabel.Scene) -> list[Issue]:
6674 """
6775 issues = []
6876
77+ # Detect calibration format once for the entire scene
78+ uses_osdar26 = _scene_uses_osdar26_calibration (scene )
79+
6980 filtered_scene = scene .filter (
7081 [
7182 IncludeObjectTypeFilter (["track" , "transition" ]),
@@ -80,7 +91,6 @@ def validate_horizon(scene: raillabel.Scene) -> list[Issue]:
8091 raise AssertionError # noqa: TRY004
8192
8293 sensor_id = annotation .sensor_id
83- uses_osdar26 = _uses_osdar26_calibration (sensor_id )
8494
8595 identifiers = IssueIdentifiers (
8696 annotation = annotation_uid ,
0 commit comments