diplomat.utils.shapes.CV2DotShapeDrawer¶
- class diplomat.utils.shapes.CV2DotShapeDrawer(img: ndarray, color: Tuple[int, int, int, int], line_thickness: int = 1, line_type: int = 8)[source]¶
Bases:
DotShapeDrawerA shape dot or marker implementation that utilizes opencv2 for drawing. It can draw to images stored as 2D numpy arrays.
- __init__(img: ndarray, color: Tuple[int, int, int, int], line_thickness: int = 1, line_type: int = 8)[source]¶
Create a cv2 marker, or shape drawer.
- Parameters:
img – The image to draw results onto, a 2D numpy array, indexed by y coordinate first.
color – The color of the dots to be drawn. Should be a tuple of 4 integers between 0 and 255 being the rgba color.
line_thickness – The thickness of the border of the dots.
line_type – The type of line to ask cv2 to draw.
Methods
__init__(img, color[, line_thickness, line_type])Create a cv2 marker, or shape drawer.
Attributes
SHAPE_TYPES- __contains__(shape: str) bool¶
Check if this shape drawer supports this shape.
- Parameters:
shape – A string representing a shape type (“square”, “circle”, etc.)
- Returns:
True if this shape drawer supports that shape, otherwise False.
- __getitem__(shape: str) Callable[[float, float, float], None]¶
Get a drawer for the provided shape type.
- Parameters:
shape – The shape to get a drawing function for, all drawers must support “circle”, “square”, “triangle”, and “star”.
- Returns:
A function or callable which accepts 3 floats (x coordinate, y coordinate, shape radius), that draws a shape marker to the specified location when called.
- __iter__()¶
Iterate over the names of the set of supported shapes.
- Returns:
Iterable of strings, the supported shapes by their names (“square”, “circle”, etc.)
- __len__()¶
Get the number of supported shapes.
- Returns:
The number of supported shapes, and integer.