Skip to content

Commit

Permalink
fix: validate_rail_side differentiates between sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
nalquas committed Nov 8, 2024
1 parent 75868d1 commit 96fc916
Showing 1 changed file with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,30 @@ def validate_rail_side(scene: raillabel.Scene) -> list[str]:
list(scene.sensors.values()), raillabel.format.SensorType.CAMERA
)

# Filter scene for track annotations in camera sensors
filtered_scene = raillabel.filter(scene, include_object_types=["track"], include_sensors=cameras)

# Check per frame
for frame_uid, frame in filtered_scene.frames.items():
# Count rails per track
counts_per_track = _count_rails_per_track_in_frame(frame)

# Add errors if there is more than one left or right rail
for object_uid, (left_count, right_count) in counts_per_track.items():
if left_count > 1:
errors.append(
f"In frame {frame_uid}, the track with object_uid {object_uid} "
f"has more than one ({left_count}) left rail."
)
if right_count > 1:
errors.append(
f"In frame {frame_uid}, the track with object_uid {object_uid} "
f"has more than one ({right_count}) right rail."
)
# Check per camera
for camera in cameras:
# Filter scene for track annotations in the selected camera sensor
filtered_scene = raillabel.filter(
scene, include_object_types=["track"], include_sensors=[camera]
)

# Check per frame
for frame_uid, frame in filtered_scene.frames.items():
# Count rails per track
counts_per_track = _count_rails_per_track_in_frame(frame)

# Add errors if there is more than one left or right rail
for object_uid, (left_count, right_count) in counts_per_track.items():
if left_count > 1:
errors.append(
f"In sensor {camera} frame {frame_uid}, the track with"
f" object_uid {object_uid} has more than one ({left_count}) left rail."
)
if right_count > 1:
errors.append(
f"In sensor {camera} frame {frame_uid}, the track with"
f" object_uid {object_uid} has more than one ({right_count}) right rail."
)

return errors

Expand Down

0 comments on commit 96fc916

Please sign in to comment.