Visualizer

DepthAI SDK visualizer serves as a tool to visualize the output of the DepthAI pipeline.

It can be used to visualize the output of the camera, neural network, depth and disparity map, the rectified streams, the spatial location of the detected objects, and more.

Getting Started

Visualizer is created upon calling OakCamera.visualize(), which returns Visualizer instance. Once it is created, the visualizer configs can be modified using output(), stereo(), text(), detections(), tracking() methods.

Example how Visualizer can be created:

from depthai_sdk import OakCamera

with OakCamera() as oak:
    cam = oak.create_camera('color')
    visualizer = oak.visualize(cam.out.main)
    oak.start(blocking=True)

Visualizer is primarily used alongside with Packets in depthai_sdk.oak_outputs module.

Configs

Visualizer is configurable via VisConfig that consists of five auxiliary configs: OutputConfig, StereoConfig, TextConfig, DetectionConfig, and TrackingConfig. Each config’s type has its own set of parameters, which effects how the corresponding object will be visualized.

There are the following methods for modifying the default configuration: output(), stereo(), text(), detections(), tracking(). The arguments should be passed as key-value arguments with the same signature as the corresponding config, e.g., Visualizer.text(font_size=2, font_color=(255,123,200)).

The modified configuration will be applied to every created objects. The methods support fluent interface and can be chained, e.g., Visualizer.text(font_size=2).detections(color=(255, 0, 0)).

Example how to configure the visualizer:

visualizer = oak.visualize(camera.out.main)
visualizer.detections(
    bbox_style=BboxStyle.RECTANGLE,
    label_position=TextPosition.MID,
).text(
    auto_scale=True
)

Objects

Visualizer operates with objects. Objects can be seen as a hierarchical structure. The root object is self, and the children are the list of the created objects. add_child should be used to add the object to the children list. The parent object shares the config and frame shape with all children.

All objects must be derived from GenericObject.

Implemented objects:

Objects can be added to the visualizer using the following methods:

Create your own object

If the provided functionality is not enough, you can create your own object. To do so, you need to create a class derived from GenericObject and implement the prepare, serialize, and draw methods. The draw method should draw the object on the passed frame argument.

class YourOwnObject:
    def __init__(self, ...):
        ...

    def prepare(self) -> None:
        ...

    def serialize(self) -> str:
        ...

    def draw(self, frame) -> None:
        ...

with OakCamera() as oak:
    cam = oak.create_camera(...)
    visualizer = cam.visualize(cam.out.main)
    visualizer.add_object(YourOwnObject(...))

Example usage

The following script will visualize the output of face detection model:

from depthai_sdk import OakCamera
from depthai_sdk.visualize.configs import BboxStyle, TextPosition

with OakCamera() as oak:
    camera = oak.create_camera('color')

    det = oak.create_nn('face-detection-retail-0004', camera)

    visualizer = oak.visualize(det.out.main, fps=True)
    visualizer.detections(
        color=(0, 255, 0),
        thickness=2,
        bbox_style=BboxStyle.RECTANGLE,
        label_position=TextPosition.MID,
    ).text(
        font_color=(255, 255, 0),
        auto_scale=True
    ).tracking(
        line_thickness=5
    )

    oak.start(blocking=True)

Serialization

The visualizer provides a way to serialize the output objects to JSON, which can be used for further processing.

JSON schemas

General config

{
  "frame_shape": {
    "type": "array",
    "items": {
      "type": "integer"
    },
    "description": "Frame shape in (height, width) format."
  },
  "config": {
    "type": "object",
    "output": {
      "img_scale": {
        "type": "number",
        "minimum": 0.0,
        "maximum": 1.0,
        "default": 1.0,
        "description": "Scale of output image."
      },
      "show_fps": {
        "type": "boolean",
        "default": false,
        "description": "Show FPS on output image."
      },
      "clickable": {
        "type": "boolean",
        "default": false,
        "description": "Show disparity or depth value on mouse hover."
      }
    },
    "stereo": {
      "type": "object",
      "colorize": {
        "type": "integer",
        "default": 2,
        "description": "cv2 colormap."
      },
      "colormap": {
        "type": "integer",
        "default": 2,
        "description": "0 - gray, 1 - color, 2 - blended color and depth."
      },
      "wls_filter": {
        "type": "boolean",
        "default": false
      },
      "wls_lambda": {
        "type": "number",
        "default": 8000.0
      },
      "wls_sigma": {
        "type": "number",
        "default": 1.5
      }
    },
    "detection": {
      "type": "object",
      "thickness": {
        "type": "integer",
        "default": 1
      },
      "fill_transparency": {
        "type": "number",
        "default": 0.15,
        "minimum": 0.0,
        "maximum": 1.0,
        "description": "Transparency of bbox fill."
      },
      "box_roundness": {
        "type": "integer",
        "default": 0,
        "description": "Roundness of bbox corners, used only when bbox_style is set to BboxStyle.ROUNDED_*."
      },
      "color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "default": [0, 255, 0],
        "description": "Default bbox color in RGB format."
      },
      "bbox_style": {
        "type": "integer",
        "default": 0,
        "description": "``depthai_sdk.visualize.configs.BBoxStyle`` enum value."
      },
      "line_width": {
        "type": "number",
        "default": 0.5,
        "minimum": 0.0,
        "maximum": 1.0,
        "description": "Horizontal line width of bbox."
      },
      "line_height": {
        "type": "number",
        "default": 0.5,
        "minimum": 0.0,
        "maximum": 1.0,
        "description": "Vertical line height of bbox."
      },
      "hide_label": {
        "type": "boolean",
        "default": false,
        "description": "Hide class label on output image."
      },
      "label_position": {
        "type": "integer",
        "default": 0,
        "description": "``depthai_sdk.visualize.configs.TextPosition`` enum value."
      },
      "label_padding": {
        "type": "integer",
        "default": 10,
        "description": "Padding between label and bbox."
      }
    },
    "text": {
      "font_face": {
        "type": "integer",
        "default": 0,
        "description": "cv2 font face."
      },
      "font_color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "default": [255, 255, 255],
        "description": "Font color in RGB format."
      },
      "font_transparency": {
        "type": "number",
        "default": 0.5,
        "minimum": 0.0,
        "maximum": 1.0
      },
      "font_scale": {
        "type": "number",
        "default": 1.0
      },
      "font_thickness": {
        "type": "integer",
        "default": 2
      },
      "font_position": {
        "type": "integer",
        "default": 0,
        "description": "``depthai_sdk.visualize.configs.TextPosition`` enum value."
      },
      "bg_transparency": {
        "type": "number",
        "default": 0.5,
        "minimum": 0.0,
        "maximum": 1.0,
        "description": "Text outline transparency."
      },
      "bg_color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "default": [0, 0, 0],
        "description": "Text outline color in RGB format."
      },
      "line_type": {
        "type": "integer",
        "default": 16,
        "description": "cv2 line type."
      },
      "auto_scale": {
        "type": "boolean",
        "default": true,
        "description": "Automatically scale font size based on bbox size."
      }
    },
    "tracking": {
      "max_length": {
        "type": "integer",
        "default": -1,
        "description": "Maximum length of tracking line, -1 for infinite."
      },
      "deletion_lost_threshold": {
        "type": "integer",
        "default": 5,
        "description": "Number of frames after which lost track is deleted."
      },
      "line_thickness": {
        "type": "integer",
        "default": 1
      },
      "fading_tails": {
        "type": "boolean",
        "default": false,
        "description": "Enable fading tails - reduces line thickness over time."
      },
      "line_color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "default": [255, 255, 255],
        "description": "Tracking line color in RGB format."
      },
      "line_type": {
        "type": "integer",
        "default": 16,
        "description": "cv2 line type."
      }
    },
    "circle": {
      "thickness": {
        "type": "integer",
        "default": 1
      },
      "color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "default": [0, 255, 0],
        "description": "Circle color in RGB format."
      },
      "line_type": {
        "type": "integer",
        "default": 16,
        "description": "cv2 line type."
      }
    }
  },
  "objects": {
    "type": "array",
    "items": {
      "type": "object"
    },
    "description": "Array of objects (e.g. detection, text, line).",
    "default": []
  }
}

Objects

  • Detection:

{
  "type": "detections",
  "detections": {
    "type": "array",
    "items": {
      "type": "object",
      "bbox": {
        "type": "array",
        "items": {
          "type": "number"
        },
        "description": "bbox absolute coordinates in format [x1, y1, x2, y2]"
      },
      "label": {
        "type": "string",
        "description": "class label"
      },
      "color": {
        "type": "array",
        "items": {
          "type": "integer"
        },
        "description": "bbox color in RGB format"
      }
    }
  },
  "children": {
    "type": "array",
    "items": {
      "type": "object"
    },
    "description": "array of child objects (e.g. detection, text, line)",
    "default": []
  }
}
  • Text:

{
  "type": "text",
  "text": {
    "type": "plain_text"
  },
  "coords": {
    "type": "array",
    "items": {
      "type": "number"
    },
    "description": "The absolute coordinates of the text in the format (x1, y1)."
  }
}
  • Line:

{
  "type": "line",
  "pt1": {
    "type": "array",
    "items": {
      "type": "number"
    },
    "description": "Absolute (x, y) coordinates of the first point."
  },
  "pt2": {
    "type": "array",
    "items": {
      "type": "number"
    },
    "description": "Absolute (x, y) coordinates of the second point."
  },
  "children": {
    "type": "array",
    "items": {
      "type": "object"
    },
    "description": "array of child objects (e.g. detection, text, line).",
    "default": []
  }
}

Example JSON output

{
  "frame_shape": [720, 1280],
  "config": {
    "output": {
      "img_scale": 1.0,
      "show_fps": false,
      "clickable": true
    },
    "stereo": {
      "colorize": 2,
      "colormap": 2,
      "wls_filter": false,
      "wls_lambda": 8000,
      "wls_sigma": 1.5
    },
    "detection": {
      "thickness": 1,
      "fill_transparency": 0.15,
      "box_roundness": 0,
      "color": [0, 255, 0],
      "bbox_style": 0,
      "line_width": 0.5,
      "line_height": 0.5,
      "hide_label": false,
      "label_position": 0,
      "label_padding": 10
    },
    "text": {
      "font_face": 0,
      "font_color": [255, 255, 255],
      "font_transparency": 0.5,
      "font_scale": 1.0,
      "font_thickness": 2,
      "font_position": 0,
      "bg_transparency": 0.5,
      "bg_color": [0, 0, 0],
      "line_type": 16,
      "auto_scale": true
    },
    "tracking": {
      "max_length": -1,
      "deletion_lost_threshold": 5,
      "line_thickness": 1,
      "fading_tails": false,
      "line_color": [255, 255, 255],
      "line_type": 16
    },
    "circle": {
      "thickness": 1,
      "color": [255, 255, 255],
      "line_type": 16
    }
  },
  "objects": [
    {
      "type": "detections",
      "detections": [
        {
          "bbox": [101, 437, 661, 712],
          "label": "laptop",
          "color": [210, 167, 218]
        }
      ],
      "children": [
        {
          "type": "text",
          "text": "Laptop",
          "coords": [111, 469]
        }
      ]
    }
  ]
}

References

class depthai_sdk.visualize.visualizer.Visualizer(scale=None, fps=False)
add_object(obj)

Call set_config, set_frame_shape and prepare for the object and add it to the list of objects. :param obj: The object to add.

Returns

self

Parameters

obj (depthai_sdk.visualize.objects.GenericObject) –

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_bbox(bbox, color=None, thickness=None, bbox_style=None, label=None)

Add a bounding box to the visualizer.

Parameters
  • bbox (depthai_sdk.visualize.bbox.BoundingBox) – Bounding box.

  • label (Optional[str]) – Label for the detection.

  • thickness (Optional[int]) – Bounding box thickness.

  • color (Optional[Tuple[int, int, int]]) – Bounding box color (RGB).

  • bbox_style (Optional[depthai_sdk.visualize.configs.BboxStyle]) – Bounding box style (one of depthai_sdk.visualize.configs.BboxStyle).

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_detections(detections, normalizer=None, label_map=None, spatial_points=None, label_color=None, label_background_color=None, label_background_transparency=None, is_spatial=False, bbox=None)

Add detections to the visualizer.

Parameters
  • detections (List[Union[depthai.ImgDetection, depthai.Tracklet]]) – List of detections.

  • normalizer (Optional[depthai_sdk.visualize.bbox.BoundingBox]) – Normalizer object.

  • label_map (Optional[List[Tuple[str, Tuple]]]) – List of tuples (label, color).

  • spatial_points (Optional[List[depthai.Point3f]]) – List of spatial points. None if not spatial.

  • label_color (Optional[Tuple[int, int, int]]) – Color for the label.

  • label_background_color (Optional[Tuple[int, int, int]]) – Color for the label background.

  • label_background_transparency (Optional[float]) – Transparency for the label background.

  • is_spatial – Flag that indicates if the detections are spatial.

  • bbox (Optional[Union[numpy.ndarray, Tuple[int, int, int, int]]]) – Bounding box, if there’s a detection inside a bounding box.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_text(text, coords=None, size=None, color=None, thickness=None, outline=True, background_color=None, background_transparency=0.5, bbox=None, position=<TextPosition.TOP_LEFT: 0>, padding=10)

Add text to the visualizer.

Parameters
  • text (str) – Text.

  • coords (Optional[Tuple[int, int]]) – Coordinates.

  • size (Optional[int]) – Size of the text.

  • color (Optional[Tuple[int, int, int]]) – Color of the text.

  • thickness (Optional[int]) – Thickness of the text.

  • outline (bool) – Flag that indicates if the text should be outlined.

  • background_color (Optional[Tuple[int, int, int]]) – Background color.

  • background_transparency (float) – Background transparency.

  • bbox (Optional[Union[numpy.ndarray, Tuple, depthai_sdk.visualize.bbox.BoundingBox]]) – Bounding box.

  • position (depthai_sdk.visualize.configs.TextPosition) – Position.

  • padding (int) – Padding.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_trail(tracklets, label_map, bbox=None)

Add a trail to the visualizer.

Parameters
  • tracklets (List[depthai.Tracklet]) – List of tracklets.

  • label_map (List[Tuple[str, Tuple]]) – List of tuples (label, color).

  • bbox (Optional[depthai_sdk.visualize.bbox.BoundingBox]) – Bounding box.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_circle(coords, radius, color=None, thickness=None)

Add a circle to the visualizer.

Parameters
  • coords (Tuple[int, int]) – Center of the circle.

  • radius (int) – Radius of the circle.

  • color (Optional[Tuple[int, int, int]]) – Color of the circle.

  • thickness (Optional[int]) – Thickness of the circle.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_line(pt1, pt2, color=None, thickness=None)

Add a line to the visualizer.

Parameters
  • pt1 (Tuple[int, int]) – Start coordinates.

  • pt2 (Tuple[int, int]) – End coordinates.

  • color (Optional[Tuple[int, int, int]]) – Color of the line.

  • thickness (Optional[int]) – Thickness of the line.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

add_mask(mask, alpha)

Add a mask to the visualizer.

Parameters
  • mask (numpy.ndarray) – Mask represented as uint8 numpy array.

  • alpha (float) – Transparency of the mask.

Returns

self

drawn(frame)

Draw all objects on the frame if the platform is PC. Otherwise, serialize the objects and communicate with the RobotHub application.

Parameters

frame (numpy.ndarray) – The frame to draw on.

Returns

np.ndarray if the platform is PC, None otherwise.

Return type

Optional[numpy.ndarray]

show(packet)

Show the packet on the screen.

serialize(force_reset=True)

Serialize all contained objects to JSON.

Parameters

force_reset (bool) – Flag that indicates if the objects should be cleared after serialization.

Returns

Stringified JSON.

Return type

str

reset()

Clear all objects.

output(img_scale=None, show_fps=None)

Configure the output of the visualizer.

Parameters
  • img_scale (Optional[float]) – Scale of the output image.

  • show_fps (Optional[bool]) – Flag that indicates if the FPS should be shown.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

stereo(colorize=None, colormap=None, wls_filter=None, wls_lambda=None, wls_sigma=None)
Parameters
detections(thickness=None, fill_transparency=None, bbox_roundness=None, color=None, bbox_style=None, line_width=None, line_height=None, hide_label=None, label_position=None, label_padding=None)

Configure how bounding boxes will look like. :param thickness: Thickness of the bounding box. :param fill_transparency: Transparency of the bounding box. :param bbox_roundness: Roundness of the bounding box. :param color: Color of the bounding box. :param bbox_style: Style of the bounding box. :param line_width: Width of the bbox horizontal lines CORNERS or ROUNDED_CORNERS style is used. :param line_height: Height of the bbox vertical lines when CORNERS or ROUNDED_CORNERS style is used. :param hide_label: Flag that indicates if the label should be hidden. :param label_position: Position of the label. :param label_padding: Padding of the label.

Returns

self

Parameters
Return type

depthai_sdk.visualize.visualizer.Visualizer

text(font_face=None, font_color=None, font_transparency=None, font_scale=None, font_thickness=None, font_position=None, background_transparency=None, background_color=None, outline_color=None, line_type=None, auto_scale=None)

Configure how text will look like.

Parameters
  • font_face (Optional[int]) – Font face (from cv2).

  • font_color (Optional[Tuple[int, int, int]]) – Font color.

  • font_transparency (Optional[float]) – Font transparency.

  • font_scale (Optional[float]) – Font scale.

  • font_thickness (Optional[int]) – Font thickness.

  • font_position (Optional[depthai_sdk.visualize.configs.TextPosition]) – Font position.

  • background_transparency (Optional[float]) – Text background transparency.

  • background_color (Optional[Tuple[int, int, int]]) – Text background color.

  • outline_color (Optional[Tuple[int, int, int]]) – Outline color.

  • line_type (Optional[int]) – Line type (from cv2).

  • auto_scale (Optional[bool]) – Flag that indicates if the font scale should be automatically adjusted.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

tracking(max_length=None, deletion_lost_threshold=None, line_thickness=None, fading_tails=None, show_speed=None, line_color=None, line_type=None, bg_color=None)

Configure how tracking trails will look like.

Parameters
  • max_length (Optional[int]) – Maximum length of the trail (in pixels).

  • deletion_lost_threshold (Optional[int]) – Number of consequent LOST statuses after which the trail is deleted.

  • line_thickness (Optional[int]) – Thickness of the line.

  • fading_tails (Optional[bool]) – Flag that indicates if the tails should fade.

  • show_speed (Optional[bool]) – Flag that indicates if the speed should be shown.

  • line_color (Optional[Tuple[int, int, int]]) – Color of the line.

  • line_type (Optional[int]) – Type of the line (from cv2).

  • bg_color (Optional[Tuple[int, int, int]]) – Text background color.

Returns

self

Return type

depthai_sdk.visualize.visualizer.Visualizer

segmentation(mask_alpha=None)
Parameters

mask_alpha (Optional[float]) –

Return type

depthai_sdk.visualize.visualizer.Visualizer

property frame_shape
close()
class depthai_sdk.visualize.objects.GenericObject(config=VisConfig(output=OutputConfig(img_scale=1.0, show_fps=False, clickable=True), stereo=StereoConfig(colorize=<StereoColor.RGB: 2>, colormap=array([[[128, 0, 0]], [[132, 0, 0]], [[136, 0, 0]], [[140, 0, 0]], [[144, 0, 0]], [[148, 0, 0]], [[152, 0, 0]], [[156, 0, 0]], [[160, 0, 0]], [[164, 0, 0]], [[168, 0, 0]], [[172, 0, 0]], [[176, 0, 0]], [[180, 0, 0]], [[184, 0, 0]], [[188, 0, 0]], [[192, 0, 0]], [[196, 0, 0]], [[200, 0, 0]], [[204, 0, 0]], [[208, 0, 0]], [[212, 0, 0]], [[216, 0, 0]], [[220, 0, 0]], [[224, 0, 0]], [[228, 0, 0]], [[232, 0, 0]], [[236, 0, 0]], [[240, 0, 0]], [[244, 0, 0]], [[248, 0, 0]], [[252, 0, 0]], [[255, 0, 0]], [[255, 4, 0]], [[255, 8, 0]], [[255, 12, 0]], [[255, 16, 0]], [[255, 20, 0]], [[255, 24, 0]], [[255, 28, 0]], [[255, 32, 0]], [[255, 36, 0]], [[255, 40, 0]], [[255, 44, 0]], [[255, 48, 0]], [[255, 52, 0]], [[255, 56, 0]], [[255, 60, 0]], [[255, 64, 0]], [[255, 68, 0]], [[255, 72, 0]], [[255, 76, 0]], [[255, 80, 0]], [[255, 84, 0]], [[255, 88, 0]], [[255, 92, 0]], [[255, 96, 0]], [[255, 100, 0]], [[255, 104, 0]], [[255, 108, 0]], [[255, 112, 0]], [[255, 116, 0]], [[255, 120, 0]], [[255, 124, 0]], [[255, 128, 0]], [[255, 132, 0]], [[255, 136, 0]], [[255, 140, 0]], [[255, 144, 0]], [[255, 148, 0]], [[255, 152, 0]], [[255, 156, 0]], [[255, 160, 0]], [[255, 164, 0]], [[255, 168, 0]], [[255, 172, 0]], [[255, 176, 0]], [[255, 180, 0]], [[255, 184, 0]], [[255, 188, 0]], [[255, 192, 0]], [[255, 196, 0]], [[255, 200, 0]], [[255, 204, 0]], [[255, 208, 0]], [[255, 212, 0]], [[255, 216, 0]], [[255, 220, 0]], [[255, 224, 0]], [[255, 228, 0]], [[255, 232, 0]], [[255, 236, 0]], [[255, 240, 0]], [[255, 244, 0]], [[255, 248, 0]], [[255, 252, 0]], [[254, 255, 2]], [[250, 255, 6]], [[246, 255, 10]], [[242, 255, 14]], [[238, 255, 18]], [[234, 255, 22]], [[230, 255, 26]], [[226, 255, 30]], [[222, 255, 34]], [[218, 255, 38]], [[214, 255, 42]], [[210, 255, 46]], [[206, 255, 50]], [[202, 255, 54]], [[198, 255, 58]], [[194, 255, 62]], [[190, 255, 66]], [[186, 255, 70]], [[182, 255, 74]], [[178, 255, 78]], [[174, 255, 82]], [[170, 255, 86]], [[166, 255, 90]], [[162, 255, 94]], [[158, 255, 98]], [[154, 255, 102]], [[150, 255, 106]], [[146, 255, 110]], [[142, 255, 114]], [[138, 255, 118]], [[134, 255, 122]], [[130, 255, 126]], [[126, 255, 130]], [[122, 255, 134]], [[118, 255, 138]], [[114, 255, 142]], [[110, 255, 146]], [[106, 255, 150]], [[102, 255, 154]], [[ 98, 255, 158]], [[ 94, 255, 162]], [[ 90, 255, 166]], [[ 86, 255, 170]], [[ 82, 255, 174]], [[ 78, 255, 178]], [[ 74, 255, 182]], [[ 70, 255, 186]], [[ 66, 255, 190]], [[ 62, 255, 194]], [[ 58, 255, 198]], [[ 54, 255, 202]], [[ 50, 255, 206]], [[ 46, 255, 210]], [[ 42, 255, 214]], [[ 38, 255, 218]], [[ 34, 255, 222]], [[ 30, 255, 226]], [[ 26, 255, 230]], [[ 22, 255, 234]], [[ 18, 255, 238]], [[ 14, 255, 242]], [[ 10, 255, 246]], [[ 6, 255, 250]], [[ 1, 255, 254]], [[ 0, 252, 255]], [[ 0, 248, 255]], [[ 0, 244, 255]], [[ 0, 240, 255]], [[ 0, 236, 255]], [[ 0, 232, 255]], [[ 0, 228, 255]], [[ 0, 224, 255]], [[ 0, 220, 255]], [[ 0, 216, 255]], [[ 0, 212, 255]], [[ 0, 208, 255]], [[ 0, 204, 255]], [[ 0, 200, 255]], [[ 0, 196, 255]], [[ 0, 192, 255]], [[ 0, 188, 255]], [[ 0, 184, 255]], [[ 0, 180, 255]], [[ 0, 176, 255]], [[ 0, 172, 255]], [[ 0, 168, 255]], [[ 0, 164, 255]], [[ 0, 160, 255]], [[ 0, 156, 255]], [[ 0, 152, 255]], [[ 0, 148, 255]], [[ 0, 144, 255]], [[ 0, 140, 255]], [[ 0, 136, 255]], [[ 0, 132, 255]], [[ 0, 128, 255]], [[ 0, 124, 255]], [[ 0, 120, 255]], [[ 0, 116, 255]], [[ 0, 112, 255]], [[ 0, 108, 255]], [[ 0, 104, 255]], [[ 0, 100, 255]], [[ 0, 96, 255]], [[ 0, 92, 255]], [[ 0, 88, 255]], [[ 0, 84, 255]], [[ 0, 80, 255]], [[ 0, 76, 255]], [[ 0, 72, 255]], [[ 0, 68, 255]], [[ 0, 64, 255]], [[ 0, 60, 255]], [[ 0, 56, 255]], [[ 0, 52, 255]], [[ 0, 48, 255]], [[ 0, 44, 255]], [[ 0, 40, 255]], [[ 0, 36, 255]], [[ 0, 32, 255]], [[ 0, 28, 255]], [[ 0, 24, 255]], [[ 0, 20, 255]], [[ 0, 16, 255]], [[ 0, 12, 255]], [[ 0, 8, 255]], [[ 0, 4, 255]], [[ 0, 0, 255]], [[ 0, 0, 252]], [[ 0, 0, 248]], [[ 0, 0, 244]], [[ 0, 0, 240]], [[ 0, 0, 236]], [[ 0, 0, 232]], [[ 0, 0, 228]], [[ 0, 0, 224]], [[ 0, 0, 220]], [[ 0, 0, 216]], [[ 0, 0, 212]], [[ 0, 0, 208]], [[ 0, 0, 204]], [[ 0, 0, 200]], [[ 0, 0, 196]], [[ 0, 0, 192]], [[ 0, 0, 188]], [[ 0, 0, 184]], [[ 0, 0, 180]], [[ 0, 0, 176]], [[ 0, 0, 172]], [[ 0, 0, 168]], [[ 0, 0, 164]], [[ 0, 0, 160]], [[ 0, 0, 156]], [[ 0, 0, 152]], [[ 0, 0, 148]], [[ 0, 0, 144]], [[ 0, 0, 140]], [[ 0, 0, 136]], [[ 0, 0, 132]], [[ 0, 0, 128]]], dtype=uint8), wls_filter=False, wls_lambda=8000, wls_sigma=1.5), detection=DetectionConfig(thickness=1, fill_transparency=0.15, box_roundness=0, color=(0, 255, 0), bbox_style=<BboxStyle.RECTANGLE: 0>, line_width=0.5, line_height=0.5, hide_label=False, label_position=<TextPosition.TOP_LEFT: 0>, label_padding=10), text=TextConfig(font_face=0, font_color=(255, 255, 255), font_transparency=0.5, font_scale=1.0, font_thickness=2, font_position=<TextPosition.TOP_LEFT: 0>, background_color=None, background_transparency=0.5, outline_color=(0, 0, 0), line_type=16, auto_scale=True), tracking=TrackingConfig(max_length=500, deletion_lost_threshold=5, line_thickness=1, fading_tails=False, line_color=(255, 255, 255), line_type=16, show_speed=False), circle=CircleConfig(thickness=1, color=(255, 255, 255), line_type=16)), frame_shape=None)

Generic object used by visualizer.

set_config(config)

Set the configuration for the current object.

Parameters

config (depthai_sdk.visualize.configs.VisConfig) – instance of VisConfig.

Returns

self

Return type

depthai_sdk.visualize.objects.GenericObject

set_frame_shape(frame_shape)

Set the incoming frame shape for the current object.

Parameters

frame_shape (Tuple[int, ..]) – frame shape as a tuple of (height, width, channels).

Returns

self

Return type

depthai_sdk.visualize.objects.GenericObject

prepare()

Prepare necessary data for drawing.

Returns

self

Return type

depthai_sdk.visualize.objects.GenericObject

abstract serialize()

Serialize the object to dict.

Return type

dict

add_child(child)

Add a child object to the current object.

Parameters

child (depthai_sdk.visualize.objects.GenericObject) – instance derived from GenericObject.

Returns

self

Return type

depthai_sdk.visualize.objects.GenericObject

property children

Get the children of the current object.

Returns

List of children.

class depthai_sdk.visualize.objects.VisDetections(detections, normalizer, label_map=None, label_color=None, label_background_color=None, label_background_transparency=None, spatial_points=None, is_spatial=False, parent_bbox=None)

Object that represents detections.

serialize()

Serialize the object to dict.

Return type

dict

register_detection(bbox, label, color)

Register a detection.

Parameters
  • bbox (Union[Tuple[int, ..], depthai_sdk.visualize.bbox.BoundingBox]) – Bounding box.

  • label (str) – Label.

  • color (Tuple[int, int, int]) – Color.

Return type

None

prepare()

Prepare necessary data for drawing.

Returns

self

Return type

depthai_sdk.visualize.objects.VisDetections

get_detections()

Get detections.

Returns

List of tuples (bbox, label, color).

Return type

List[Tuple[numpy.ndarray, str, Tuple[int, int, int]]]

class depthai_sdk.visualize.objects.VisText(text, coords=None, size=None, color=None, thickness=None, outline=True, background_color=None, background_transparency=0.5, bbox=None, position=<TextPosition.TOP_LEFT: 0>, padding=10)

Object that represents a text.

serialize()

Serialize the object to dict.

class depthai_sdk.visualize.objects.VisLine(pt1, pt2, color=None, thickness=None)

Object that represents a line.

serialize()

Serialize the object to dict.

prepare()

Prepare necessary data for drawing.

Returns

self

Return type

depthai_sdk.visualize.objects.VisLine

class depthai_sdk.visualize.objects.VisTrail(tracklets, label_map, bbox)

Object that represents a trail.

serialize()

Serialize the object to dict.

prepare()

Prepare necessary data for drawing.

Returns

self

Return type

depthai_sdk.visualize.objects.VisTrail

groupby_tracklet()

Group tracklets by tracklet id.

Returns

Dictionary of tracklets grouped by tracklet id.

static get_rect_centroid(rect, w, h)

Get centroid of a rectangle.

Parameters

rect (depthai.Rect) –

Return type

Tuple[int, int]

class depthai_sdk.visualize.configs.TextPosition(value)

Where on frame do we want to print text.

TOP_LEFT = 0
MID_LEFT = 1
BOTTOM_LEFT = 2
TOP_MID = 10
MID = 11
BOTTOM_MID = 12
TOP_RIGHT = 20
MID_RIGHT = 21
BOTTOM_RIGHT = 22
class depthai_sdk.visualize.configs.BboxStyle(value)

How do we want to draw bounding box.

RECTANGLE = 0
CORNERS = 1
ROUNDED_RECTANGLE = 10
ROUNDED_CORNERS = 11
class depthai_sdk.visualize.configs.StereoColor(value)

An enumeration.

GRAY = 1
RGB = 2
RGBD = 3
class depthai_sdk.visualize.configs.OutputConfig(img_scale=1.0, show_fps=False, clickable=True)

Configuration for output of the visualizer.

img_scale: float = 1.0
show_fps: bool = False
clickable: bool = True
class depthai_sdk.visualize.configs.StereoConfig(colorize: depthai_sdk.visualize.configs.StereoColor = <StereoColor.RGB: 2>, colormap: numpy.ndarray = <factory>, wls_filter: bool = False, wls_lambda: float = 8000, wls_sigma: float = 1.5)
colorize: depthai_sdk.visualize.configs.StereoColor = 2
colormap: numpy.ndarray
wls_filter: bool = False
wls_lambda: float = 8000
wls_sigma: float = 1.5
class depthai_sdk.visualize.configs.DetectionConfig(thickness=1, fill_transparency=0.15, box_roundness=0, color=(0, 255, 0), bbox_style=<BboxStyle.RECTANGLE: 0>, line_width=0.5, line_height=0.5, hide_label=False, label_position=<TextPosition.TOP_LEFT: 0>, label_padding=10)

Configuration for drawing bounding boxes.

thickness: int = 1
fill_transparency: float = 0.15
box_roundness: int = 0
color: Tuple[int, int, int] = (0, 255, 0)
bbox_style: depthai_sdk.visualize.configs.BboxStyle = 0
line_width: float = 0.5
line_height: float = 0.5
hide_label: bool = False
label_position: depthai_sdk.visualize.configs.TextPosition = 0
label_padding: int = 10
class depthai_sdk.visualize.configs.TextConfig(font_face=0, font_color=(255, 255, 255), font_transparency=0.5, font_scale=1.0, font_thickness=2, font_position=<TextPosition.TOP_LEFT: 0>, background_color=None, background_transparency=0.5, outline_color=(0, 0, 0), line_type=16, auto_scale=True)

Configuration for drawing labels.

font_face: int = 0
font_color: Tuple[int, int, int] = (255, 255, 255)
font_transparency: float = 0.5
font_scale: float = 1.0
font_thickness: int = 2
font_position: depthai_sdk.visualize.configs.TextPosition = 0
background_color: Optional[Tuple[int, int, int]] = None
background_transparency: float = 0.5
outline_color: Tuple[int, int, int] = (0, 0, 0)
line_type: int = 16
auto_scale: bool = True
class depthai_sdk.visualize.configs.TrackingConfig(max_length=500, deletion_lost_threshold=5, line_thickness=1, fading_tails=False, line_color=(255, 255, 255), line_type=16, show_speed=False)

Configuration for drawing tracking bounding boxes.

max_length: int = 500
deletion_lost_threshold: int = 5
line_thickness: int = 1
fading_tails: bool = False
line_color: Tuple[int, int, int] = (255, 255, 255)
line_type: int = 16
show_speed: bool = False
class depthai_sdk.visualize.configs.SegmentationConfig(mask_alpha=0.5)

Configuration for drawing segmentation masks.

mask_alpha: float = 0.5
class depthai_sdk.visualize.configs.CircleConfig(thickness=1, color=(255, 255, 255), line_type=16)

Configuration for drawing circles.

thickness: int = 1
color: Tuple[int, int, int] = (255, 255, 255)
line_type: int = 16
class depthai_sdk.visualize.configs.VisConfig(output=<factory>, stereo=<factory>, detection=<factory>, text=<factory>, tracking=<factory>, circle=<factory>)

Configuration for visualizer.

output: depthai_sdk.visualize.configs.OutputConfig
stereo: depthai_sdk.visualize.configs.StereoConfig
detection: depthai_sdk.visualize.configs.DetectionConfig
text: depthai_sdk.visualize.configs.TextConfig
tracking: depthai_sdk.visualize.configs.TrackingConfig
circle: depthai_sdk.visualize.configs.CircleConfig

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.