l5kit.visualization package

l5kit.visualization.draw_reference_trajectory(on_image: numpy.ndarray, world_to_pixel: numpy.ndarray, positions: numpy.ndarray) None

Draw a trajectory (as points) onto the image :param on_image: the RGB image to draw onto :type on_image: np.ndarray :param world_to_pixel: 3x3 matrix from meters to ego pixel space :type world_to_pixel: np.ndarray :param positions: positions as 2D absolute meters coordinates :type positions: np.ndarray

Returns: None

l5kit.visualization.draw_trajectory(on_image: numpy.ndarray, positions: numpy.ndarray, rgb_color: Tuple[int, int, int], radius: int = 1, yaws: Optional[numpy.ndarray] = None) None

Draw a trajectory on oriented arrow onto an RGB image :param on_image: the RGB image to draw onto :type on_image: np.ndarray :param positions: pixel coordinates in the image space (not displacements) (Nx2) :type positions: np.ndarray :param rgb_color: the trajectory RGB color :type rgb_color: Tuple[int, int, int] :param radius: radius of the circle :type radius: int :param yaws: yaws in radians (N) or None to disable yaw visualisation :type yaws: Optional[np.ndarray]

Returns: None

l5kit.visualization.write_gif(output_filepath: str, images: Iterable[numpy.ndarray], resolution: Tuple[int, int], fps: float = 24.0, loop: int = 0, interpolation: int = 2) None

Writes input RGB images to given output gif filepath using imageio. It resizes images if necessary using given interpolation (default=``cv2.INTER_CUBIC``).

Parameters
  • output_filepath (str) – output filepath, should end in .gif

  • images (Iterable[np.ndarray]) – a list or other iterable of images.

  • resolution (Tuple[int, int]) – desired resolution, e.g. (512, 512)

Keyword Arguments
  • fps (float) – Frames per second (default: {24.0})

  • loop (int) – 0 means loop forever, any other number loops the GIF that many times (default: {0})

  • interpolation (int) – Interpolation to be used when resizing (default: {cv2.INTER_CUBIC})

l5kit.visualization.write_video(output_filepath: str, images: Iterable[numpy.ndarray], resolution: Tuple[int, int], fps: float = 24.0, codec: str = 'FMP4', interpolation: int = 2) None

Writes input RGB images to given output video filepath using OpenCV. It resizes images if necessary using given interpolation (default=``cv2.INTER_CUBIC``).

Note that as this function uses OpenCV, your image’s color channels will be inverted (RGB -> BGR) prior to writing.

Parameters
  • output_filepath (str) – output filepath, generally this should end in .mp4 or .avi

  • used. (depending on the codec) –

  • images (Iterable[np.ndarray]) – a list or other iterable of images.

  • resolution (Tuple[int, int]) – video resolution, e.g. (512, 512), the input frames are resized to this.

Keyword Arguments
  • fps (float) – Frames per second (default: {24.0})

  • codec (str) – Codec to be used. Note that with X264 codec only certain resolutions may work (default: {“FMP4”})

  • interpolation (int) – Interpolation to be used when resizing (default: {cv2.INTER_CUBIC})

Subpackages

Submodules