# annotation_helper

Python API: `depthai_nodes.utils.annotation_helper`

## Classes

### AnnotationHelper

Simplifies `dai.ImgAnnotation` creation.

After calling the desired drawing methods, call the `build` method to create the `ImgAnnotations` message.

#### Methods

##### init

```python
def __init__(viewport_clipper: ViewportClipper | None = None):
```

Create an empty annotation builder.

Parameters

 * `viewport_clipper` (`ViewportClipper | None`): Optional clipping bounds. Defaults to the normalized unit viewport [0, 1] on
   both axes.

##### build

```python
def build(timestamp: timedelta, sequence_num: int) -> dai.ImgAnnotations:
```

Creates an ImgAnnotations message.

Parameters

 * `timestamp` (`timedelta`): Message timestamp
 * `sequence_num` (`int`): Message sequence number

Returns

 * `dai.ImgAnnotations`: Created ImgAnnotations message

##### draw_circle

```python
def draw_circle(center: Point | dai.Point2f, radius: float, outline_color: ColorRGBA | dai.Color = PRIMARY_COLOR, fill_color: ColorRGBA | None | dai.Color | None = None, thickness: float = 1.0) -> AnnotationHelper:
```

Draws a circle.

Parameters

 * `center` (`Point | dai.Point2f`): Center of the circle
 * `radius` (`float`): Radius of the circle
 * `outline_color` (`ColorRGBA | dai.Color`): Outline color
 * `fill_color` (`ColorRGBA | None | dai.Color | None`): Fill color (None for no fill)
 * `thickness` (`float`): Outline thickness

Returns

 * `AnnotationHelper`: self

##### draw_line

```python
def draw_line(pt1: Point | dai.Point2f, pt2: Point | dai.Point2f, color: ColorRGBA | dai.Color = PRIMARY_COLOR, thickness: float = 2.0, clip_to_viewport: bool = False) -> AnnotationHelper:
```

Draws a line between two points.

Parameters

 * `pt1` (`Point | dai.Point2f`): Start of the line
 * `pt2` (`Point | dai.Point2f`): End of the line
 * `color` (`ColorRGBA | dai.Color`): Line color
 * `thickness` (`float`): Line thickness
 * `clip_to_viewport` (`bool`): Indication whether to clip the line to the viewport

Returns

 * `AnnotationHelper`: self

##### draw_points

```python
def draw_points(points: list[Point] | list[dai.Point2f] | dai.VectorPoint2f, color: ColorRGBA | dai.Color = PRIMARY_COLOR, thickness: float = 2.0) -> AnnotationHelper:
```

Draws points.

Parameters

 * `points` (`list[Point] | list[dai.Point2f] | dai.VectorPoint2f`): List of points to draw
 * `color` (`ColorRGBA | dai.Color`): Color of the points
 * `thickness` (`float`): Size of the points

Returns

 * `AnnotationHelper`: self

##### draw_polyline

```python
def draw_polyline(points: list[Point] | list[dai.Point2f], outline_color: ColorRGBA | dai.Color = PRIMARY_COLOR, fill_color: ColorRGBA | None | dai.Color | None = TRANSPARENT_PRIMARY_COLOR, thickness: float = 1.0, closed: bool = False) -> AnnotationHelper:
```

Draws a polyline.

Parameters

 * `points` (`list[Point] | list[dai.Point2f]`): List of points of the polyline
 * `outline_color` (`ColorRGBA | dai.Color`): Outline color
 * `fill_color` (`ColorRGBA | None | dai.Color | None`): Fill color (None for no fill)
 * `thickness` (`float`): Line thickness
 * `closed` (`bool`): Creates polygon, instead of polyline if True

Returns

 * `AnnotationHelper`: self

##### draw_rectangle

```python
def draw_rectangle(top_left: Point | dai.Point2f, bottom_right: Point | dai.Point2f, outline_color: ColorRGBA | dai.Color = PRIMARY_COLOR, fill_color: ColorRGBA | None | dai.Color | None = TRANSPARENT_PRIMARY_COLOR, thickness: float = 1.0, clip_to_viewport: bool = False) -> AnnotationHelper:
```

Draws a rectangle.

Parameters

 * `top_left` (`Point | dai.Point2f`): Top left corner of the rectangle
 * `bottom_right` (`Point | dai.Point2f`): Bottom right corner of the rectangle
 * `outline_color` (`ColorRGBA | dai.Color`): Outline color
 * `fill_color` (`ColorRGBA | None | dai.Color | None`): Fill color (None for no fill)
 * `thickness` (`float`): Outline thickness
 * `clip_to_viewport` (`bool`): Indication whether to clip the line to the viewport

Returns

 * `AnnotationHelper`: self

##### draw_rotated_rect

```python
def draw_rotated_rect(center: Point | dai.Point2f, size: tuple[float, float] | dai.Size2f, angle: float, outline_color: ColorRGBA | dai.Color = PRIMARY_COLOR, fill_color: ColorRGBA | None | dai.Color | None = TRANSPARENT_PRIMARY_COLOR, thickness: float = 1.0, clip_to_viewport: bool = False) -> AnnotationHelper:
```

Draws a rotated rectangle.

Parameters

 * `center` (`Point | dai.Point2f`): Center of the rectangle
 * `size` (`tuple[float, float] | dai.Size2f`): Size of the rectangle (width, height)
 * `angle` (`float`): Angle of rotation in degrees
 * `outline_color` (`ColorRGBA | dai.Color`): Outline color
 * `fill_color` (`ColorRGBA | None | dai.Color | None`): Fill color (None for no fill)
 * `thickness` (`float`): Outline thickness
 * `clip_to_viewport` (`bool`): Indication whether to clip the line to the viewport

Returns

 * `AnnotationHelper`: self

##### draw_text

```python
def draw_text(text: str, position: Point | dai.Point2f, color: ColorRGBA | dai.Color = PRIMARY_COLOR, background_color: ColorRGBA | None | dai.Color | None = None, size: float = 32) -> AnnotationHelper:
```

Draws text.

Parameters

 * `text` (`str`): Text string
 * `position` (`Point | dai.Point2f`): Text position
 * `color` (`ColorRGBA | dai.Color`): Text color
 * `background_color` (`ColorRGBA | None | dai.Color | None`): Background color (None for no background)
 * `size` (`float`): Text size

Returns

 * `AnnotationHelper`: self

#### Attributes

##### annotation

## Attributes

### ColorRGBA

### Point
