vis4d.vis.image.bounding_box_visualizer

Bounding box visualizer.

Classes

BoundingBoxVisualizer(*args[, n_colors, ...])

Bounding box visualizer class.

DataSample(image, image_name, boxes)

Dataclass storing a data sample that can be visualized.

DetectionBox2D(corners, label, color)

Dataclass storing box informations.

class DetectionBox2D(corners, label, color)[source]

Dataclass storing box informations.

class DataSample(image, image_name, boxes)[source]

Dataclass storing a data sample that can be visualized.

class BoundingBoxVisualizer(*args, n_colors=50, cat_mapping=None, file_type='png', width=2, canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>, **kwargs)[source]

Bounding box visualizer class.

__init__(*args, n_colors=50, cat_mapping=None, file_type='png', width=2, canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>, **kwargs)[source]

Creates a new Visualizer for Image and Bounding Boxes.

Parameters:
  • n_colors (int) – How many colors should be used for the internal color map

  • cat_mapping (dict[str, int]) – Mapping from class names to class ids. Defaults to None.

  • file_type (str) – Desired file type. Defaults to “png”.

  • width (int) – Width of the bounding box lines. Defaults to 2.

  • canvas (CanvasBackend) – Backend that is used to draw on images.

  • viewer (ImageViewerBackend) – Backend that is used show images.

__repr__()[source]

Return string representation of the visualizer.

Return type:

str

reset()[source]

Reset visualizer.

Return type:

None

process(cur_iter, images, image_names, boxes, scores=None, class_ids=None, track_ids=None, categories=None)[source]

Processes a batch of data.

Parameters:
  • cur_iter (int) – Current iteration.

  • images (list[ArrayLike]) – Images to show.

  • image_names (list[str]) – Image names.

  • boxes (list[ArrayLikeFloat]) – List of predicted bounding boxes with shape [N, (x1, y1, x2, y2)], where N is the number of boxes.

  • scores (None | list[ArrayLikeFloat], optional) – List of predicted box scores each of shape [N]. Defaults to None.

  • class_ids (None | list[ArrayLikeInt], optional) – List of predicted class ids each of shape [N]. Defaults to None.

  • track_ids (None | list[ArrayLikeInt], optional) – List of predicted track ids each of shape [N]. Defaults to None.

  • categories (None | list[list[str]], optional) – List of categories for each image. Instead of class ids, the categories will be used to label the boxes. Defaults to None.

Return type:

None

process_single_image(image, image_name, boxes, scores=None, class_ids=None, track_ids=None, categories=None)[source]

Processes a single image entry.

Parameters:
  • image (ArrayLike) – Image to show.

  • image_name (str) – Image name.

  • boxes (ArrayLikeFloat) – Predicted bounding boxes with shape [N, (x1,y1,x2,y2)], where N is the number of boxes.

  • scores (None | ArrayLikeFloat, optional) – Predicted box scores of shape [N]. Defaults to None.

  • class_ids (None | ArrayLikeInt, optional) – Predicted class ids of shape [N]. Defaults to None.

  • track_ids (None | ArrayLikeInt, optional) – Predicted track ids of shape [N]. Defaults to None.

  • categories (None | list[str], optional) – List of categories for each box. Instead of class ids, the categories will be used to label the boxes. Defaults to None.

Return type:

None

show(cur_iter, blocking=True)[source]

Shows the processed images in a interactive window.

Parameters:
  • cur_iter (int) – Current iteration.

  • blocking (bool) – If the visualizer should be blocking i.e. wait for human input for each image. Defaults to True.

Return type:

None

save_to_disk(cur_iter, output_folder)[source]

Saves the visualization to disk.

Writes all processes samples to the output folder naming each image <sample.image_name>.<filetype>.

Parameters:
  • cur_iter (int) – Current iteration.

  • output_folder (str) – Folder where the output should be written.

Return type:

None