Skip to content

Commit ac5294c

Browse files
authored
Merge pull request #37 from dbinfrago/feature/osdar26-ontology-and-validation-improvements
Feature/osdar26 ontology and validation improvements
2 parents c17328c + f7afca1 commit ac5294c

2 files changed

Lines changed: 30 additions & 9 deletions

File tree

raillabel_providerkit/_util/_sensor_metadata.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from raillabel.format import Camera, GpsImu, Lidar, Radar
55

66
SENSOR_METADATA = {
7+
# OSDAR23 sensors
78
"rgb_center": Camera,
89
"rgb_left": Camera,
910
"rgb_right": Camera,
@@ -19,4 +20,14 @@
1920
"lidar": Lidar,
2021
"radar": Radar,
2122
"gps_imu": GpsImu,
23+
# OSDAR26 sensors
24+
"rgb_12mp_left": Camera,
25+
"rgb_12mp_middle": Camera,
26+
"rgb_12mp_right": Camera,
27+
"rgb_5mp_left": Camera,
28+
"rgb_5mp_middle": Camera,
29+
"rgb_5mp_right": Camera,
30+
"ir_middle": Camera,
31+
"lidar_merged": Lidar,
32+
"radar_cartesian": Radar,
2233
}

raillabel_providerkit/validation/validate_horizon/validate_horizon.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,39 @@
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

5057
def 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

Comments
 (0)