From 96fc9163379a182755f592391bc0f72b09720802 Mon Sep 17 00:00:00 2001 From: Niklas Freund Date: Fri, 8 Nov 2024 11:31:14 +0100 Subject: [PATCH] fix: validate_rail_side differentiates between sensors --- .../validate_rail_side/validate_rail_side.py | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/raillabel_providerkit/validation/validate_rail_side/validate_rail_side.py b/raillabel_providerkit/validation/validate_rail_side/validate_rail_side.py index 60b71bb..1ec3478 100644 --- a/raillabel_providerkit/validation/validate_rail_side/validate_rail_side.py +++ b/raillabel_providerkit/validation/validate_rail_side/validate_rail_side.py @@ -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