vis4d.vis.functional

Function interface for visualization functions.

draw_bboxes(image, boxes, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>)[source]

Draws the predicted bounding boxes into the given image.

Parameters:
  • image (ArrayLike) – The image to draw the bboxes into.

  • boxes (ArrayLikeFloat) – Predicted bounding boxes.

  • scores (None | ArrayLikeFloat, optional) – Predicted scores. Defaults to None.

  • class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.

  • track_ids (ArrayLikeInt, optional) – Predicted track ids. Defaults to None.

  • class_id_mapping (dict[int, str], optional) – Mapping from class id to name. Defaults to None.

  • n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.

  • image_mode (str, optional) – Image Mode. Defaults to “RGB”.

  • box_width (int, optional) – Width of the box border. Defaults to 1.

  • canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().

Returns:

The image with boxes drawn into it,

Return type:

NDArrayUI8

draw_masks(image, masks, class_ids, n_colors=50, image_mode='RGB', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>)[source]

Draws semantic masks into the given image.

Parameters:
  • image (ArrayLike) – The image to draw the bboxes into.

  • masks (ArrayLikeBool) – The semantic masks with the same shape as the image.

  • class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.

  • n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.

  • image_mode (str, optional) – Image Mode. Defaults to “RGB”.

  • canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().

Returns:

The image with semantic masks drawn into it,

Return type:

NDArrayUI8

draw_points(points_xyz, colors=None, classes=None, instances=None, transform=None, scene=None)[source]

Adds pointcloud data to a 3D scene for visualization purposes.

Parameters:
  • points_xyz (ArrayLikeFloat) – xyz coordinates of the points shape [N, 3]

  • classes (ArrayLikeInt | None) – semantic ids of the points shape [N, 1]

  • instances (ArrayLikeInt | None) – instance ids of the points shape [N, 1]

  • colors (ArrayLikeFloat | None) – colors of the points shape [N,3] and ranging from [0,1]

  • transform (ArrayLikeFloat | None) – Optional 4x4 SE3 transform that transforms the point data into a static reference frame.

  • scene (Scene3D | None) – Visualizer that should be used to display the data.

Return type:

Scene3D

imshow(image, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]

Shows a single image.

Parameters:
  • image (NDArrayNumber) – The image to show.

  • image_mode (str, optional) – Image Mode. Defaults to “RGB”.

  • image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().

Return type:

None

imshow_bboxes(image, boxes, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]

Shows the bounding boxes overlayed on the given image.

Parameters:
  • image (ArrayLike) – Background Image

  • boxes (ArrayLikeFloat) – Boxes to show. Shape [N, 4] with (x1,y1,x2,y2) as corner convention

  • scores (ArrayLikeFloat, optional) – Score for each box shape [N]

  • class_ids (ArrayLikeInt, optional) – Class id for each box shape [N]

  • track_ids (ArrayLikeInt, optional) – Track id for each box shape [N]

  • class_id_mapping (dict[int, str], optional) – Mapping to convert class id to class name

  • n_colors (int, optional) – Number of distinct colors used to color the boxes. Defaults to 50.

  • image_mode (str, optional) – Image channel mode (RGB or BGR).

  • box_width (int, optional) – Width of the box border. Defaults to 1.

  • image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().

Return type:

None

imshow_masks(image, masks, class_ids, n_colors=50, image_mode='RGB', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]

Shows semantic masks overlayed over the given image.

Parameters:
  • image (ArrayLike) – The image to draw the bboxes into.

  • masks (ArrayLikeBool) – The semantic masks with the same shape as the image.

  • class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.

  • n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.

  • image_mode (str, optional) – Image Mode.. Defaults to “RGB”.

  • canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().

  • image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().

Return type:

None

imshow_topk_bboxes(image, boxes, scores, topk=100, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]

Visualize the ‘topk’ bounding boxes with highest score.

Parameters:
  • image (ArrayLike) – Background Image

  • boxes (ArrayLikeFloat) – Boxes to show. Shape [N, 4] with (x1,y1,x2,y2) as corner convention

  • scores (ArrayLikeFloat) – Score for each box shape [N]

  • topk (int) – Number of boxes to visualize

  • class_ids (ArrayLikeInt, optional) – Class id for each box shape [N]

  • track_ids (ArrayLikeInt, optional) – Track id for each box shape [N]

  • class_id_mapping (dict[int, str], optional) – Mapping to convert class id to class name

  • n_colors (int, optional) – Number of distinct colors used to color the boxes. Defaults to 50.

  • image_mode (str, optional) – Image channel mode (RGB or BGR).

  • box_width (int, optional) – Width of the box border. Defaults to 1.

  • image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().

Return type:

None

imshow_track_matches(key_imgs, ref_imgs, key_boxes, ref_boxes, key_track_ids, ref_track_ids, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]

Visualize paired bounding boxes successively for batched frame pairs.

Parameters:
  • key_imgs (list[ArrayLike]) – Key Images.

  • ref_imgs (list[ArrayLike]) – Reference Images.

  • key_boxes (list[ArrayLikeFloat]) – Predicted Boxes for the key image. Shape [N, 4]

  • ref_boxes (list[ArrayLikeFloat]) – Predicted Boxes for the key image. Shape [N, 4]

  • key_track_ids (list[ArrayLikeInt]) – Predicted ids for the key images.

  • ref_track_ids (list[ArrayLikeInt]) – Predicted ids for the reference images.

  • image_mode (str, optional) – Color mode if the image. Defaults to “RGB”.

  • image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().

Return type:

None

show_3d(scene, viewer=<vis4d.vis.pointcloud.viewer.open3d_viewer.Open3DVisualizationBackend object>)[source]

Shows a given 3D scene.

This method shows a 3D visualization of a given 3D scene. Use the viewer attribute to use different visualization backends (e.g. open3d)

Parameters:
  • scene (Scene3D) – The 3D scene that should be visualized.

  • viewer (PointCloudVisualizerBackend, optional) – The Visualization backend that should be used to visualize the scene. Defaults to Open3DVisualizationBackend.

Return type:

None

show_points(points_xyz, colors=None, classes=None, instances=None, transform=None, viewer=<vis4d.vis.pointcloud.viewer.open3d_viewer.Open3DVisualizationBackend object>)[source]

Visualizes a pointcloud with color and semantic information.

Parameters:
  • points_xyz (ArrayLikeFloat) – xyz coordinates of the points shape [N, 3]

  • classes (ArrayLikeInt | None) – semantic ids of the points shape [N, 1]

  • instances (ArrayLikeInt | None) – instance ids of the points shape [N, 1]

  • colors (ArrayLikeFloat | None) – colors of the points shape [N,3] and ranging from [0,1]

  • transform (ArrayLikeFloat | None) – Optional 4x4 SE3 transform that transforms the point data into a static reference frame

  • viewer (PointCloudVisualizerBackend, optional) – The Visualization backend that should be used to visualize the scene. Defaults to Open3DVisualizationBackend.

Return type:

None

Modules

vis4d.vis.functional.image

Function interface for image visualization functions.

vis4d.vis.functional.pointcloud

Function interface for point cloud visualization functions.