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 BoundingBoxVisualizer(*args, n_colors=50, class_id_mapping=None, file_type='png', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>, **kwargs)[source]

Bounding box visualizer class.

Creates a new Visualizer for Image and Bounding Boxes.

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

  • class_id_mapping (dict[int, str]) – Mapping from class id to human readable name

  • file_type (str) – Desired file type

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

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

process(cur_iter, images, image_names, boxes, scores=None, class_ids=None, track_ids=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.

Return type:

None

process_single_image(image, image_name, boxes, scores=None, class_ids=None, track_ids=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.

Return type:

None

reset()[source]

Reset visualizer.

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

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

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

Dataclass storing a data sample that can be visualized.

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

Dataclass storing box informations.