l5kit.data.filter module¶
- l5kit.data.filter.filter_agents_by_distance(agents: numpy.ndarray, centroid: numpy.ndarray, max_distance: float) numpy.ndarray ¶
Filter agents by distance, cut to max_distance and sort the result :param agents: array of agents :type agents: np.ndarray :param centroid: centroid towards which compute distance :type centroid: np.ndarray :param max_distance: max distance to cut off :type max_distance: float
- Returns
agents sorted and cut to max_distance
- Return type
np.ndarray
- l5kit.data.filter.filter_agents_by_frames(frames: numpy.ndarray, agents: numpy.ndarray) List[numpy.ndarray] ¶
Get a list of agents array, one array per frame. Note that “agent_index_interval” is used to filter agents, so you should take care of re-setting it if you have previously sliced agents.
- Parameters
frames (np.ndarray) – an array of frames
agents (np.ndarray) – an array of agents
- Returns
List[np.ndarray] with the agents divided by frame
- l5kit.data.filter.filter_agents_by_labels(agents: numpy.ndarray, threshold: float = 0.5) numpy.ndarray ¶
Filters an agents array, keeping those agents that meet the threshold.
- Parameters
agents (np.ndarray) – Agents array
- Keyword Arguments
threshold (float) – probability threshold for filtering (default: {0.5})
- Returns
np.ndarray – A subset of input
agents
array.
- l5kit.data.filter.filter_agents_by_track_id(agents: numpy.ndarray, track_id: int) numpy.ndarray ¶
Return all agent object (np.ndarray) of a given track_id.
- Parameters
agents (np.ndarray) – agents array. NOTE: do NOT pass a zarr to this function, it can’t handle boolean indexing
track_id (int) – agent track id to select
- Returns
np.ndarray – Selected agent.
- l5kit.data.filter.filter_tl_faces_by_frames(frames: numpy.ndarray, tl_faces: numpy.ndarray) List[numpy.ndarray] ¶
Get a list of traffic light faces arrays, one array per frame. This functions mimics filter_agents_by_frames for traffic light faces
- Parameters
frames (np.ndarray) – an array of frames
tl_faces (np.ndarray) – an array of traffic light faces
- Returns
List[np.ndarray] with the traffic light faces divided by frame
- l5kit.data.filter.filter_tl_faces_by_status(tl_faces: numpy.ndarray, status: str) numpy.ndarray ¶
Filter tl_faces and keep only active faces :param tl_faces: array of traffic faces :type tl_faces: np.ndarray :param status: status we want to keep TODO refactor for enum :type status: str
- Returns
traffic light faces array with only faces with that status
- Return type
np.ndarray
- l5kit.data.filter.get_agents_slice_from_frames(frame_a: numpy.ndarray, frame_b: Optional[numpy.ndarray] = None) slice ¶
Get a slice for indexing agents giving a start and end frame
- Parameters
frame_a (np.ndarray) – the starting frame
frame_b (Optional[np.ndarray]) – the ending frame. If None, then frame_a end will be used
- Returns
a slice object starting from the first agent in frame_a to the last one in frame_b
- Return type
slice
- l5kit.data.filter.get_frames_slice_from_scenes(scene_a: numpy.ndarray, scene_b: Optional[numpy.ndarray] = None) slice ¶
Get a slice for indexing frames giving a start and end scene
- Parameters
scene_a (np.ndarray) – the starting scene
scene_b (Optional[np.ndarray]) – the ending scene. If None, then scene_a end will be used
- Returns
a slice object starting from the first frame in scene_a to the last one in scene_b
- Return type
slice
- l5kit.data.filter.get_other_agents_ids(all_agents_ids: numpy.ndarray, priority_ids: numpy.ndarray, selected_track_id: Optional[int], max_agents: int) List[numpy.uint64] ¶
Get ids of agents around selected_track_id. Give precedence to priority_ids over all_agents_ids and cut to max_agents :param all_agents_ids: ids of all the agents from present to past :type all_agents_ids: np.ndarray :param priority_ids: ids of agents we know are reliable in the present :type priority_ids: np.ndarray :param selected_track_id: current id of the agent of interest :type selected_track_id: Optional[int] :param max_agents: max agents to take :type max_agents: int
- Returns
the list of track ids of agents to take
- Return type
List[np.uint64]
- l5kit.data.filter.get_tl_faces_slice_from_frames(frame_a: numpy.ndarray, frame_b: Optional[numpy.ndarray] = None) slice ¶
Get a slice for indexing traffic light faces giving a start and end frame
- Parameters
frame_a (np.ndarray) – the starting frame
frame_b (Optional[np.ndarray]) – the ending frame. If None, then frame_a end will be used
- Returns
a slice object starting from the first tl_face in frame_a to the last one in frame_b
- Return type
slice