BBoxes¶
- class vizdet.ColorMode(value)¶
Determines what the color of the bounding box is based on.
- IDS = 2¶
- LABELS = 1¶
- class vizdet.BBoxes(font=<factory>, labels_list=None, text_color=(0, 0, 0), bbox_color_list=((238, 119, 51), (0, 118, 187), (51, 188, 238), (238, 51, 120), (204, 51, 17), (0, 153, 135), (187, 187, 187)), color_mode=ColorMode.LABELS, box_thickness=2, padding=2, separator=' | ', font_height=15)¶
The class for drawing bounding boxes and associated labels of detected objects.
- Parameters
font (
Font
) – The label font. If not set, the default font will be used.labels_list (
Optional
[Sequence
[str
]]) – A list of possible labels. If set, the labels passed to thedraw_boxes()
method should be integer indices corresponding to the labels inlabels_list
. These (text) labels will then be drawn.text_color (
Tuple
[int
,int
,int
]) – Color of the label text.bbox_color_list (
Sequence
[Tuple
[int
,int
,int
]]) – A list of colors in RGB format to use for bounding boxes.color_mode (
ColorMode
) – Whether to color bounding boxes based in class or item ids.box_thickness (
int
) – Thickness of the bounding box.padding (
int
) – How many pixels to pad the label background on each side.separator (
str
) – What to separate different parts of the text label withfont_height (
int
) – Label font height.
- Return type
None
- draw(img, bboxes, ids=None, labels=None, scores=None)¶
Draw the bounding boxes with their labels.
The bounding boxes are drawn as specified in
bboxes
, and the label is drawn on the upper left part of the box. Any object information (label, item IDs for tracking, label scores) will be added to the label, and separated by “|”.The color of the boxes depends either on the labels or item IDs, as was specified in
color_mode
. If the color depends on labels, and labels are passed as strings, their contents will be hashed to obtain a numeric index in the color list.If
labels_list
was set, thenlabels
should be integer indices, and the value displayed will be the string fromlabels_list
corresponding to the index.This method edits the
img
in place and does not return any value.- Parameters
img (
ndarray
) – The image to draw bounding boxes on.bboxes (
Union
[Sequence
[Tuple
[int
,int
,int
,int
]],ndarray
]) – Coordinates of bounding boxes in the[xmin, ymin, xmax, ymax]
format. Elements should be integers.ids (
Union
[Sequence
[int
],None
,ndarray
]) – Item IDs from tracking.labels (
Union
[Sequence
[Union
[str
,int
]],None
,ndarray
]) – Item labels (classes). Iflabels_list
is set labels should be intigers corresponding to indices of that list.scores (
Union
[Sequence
[float
],None
,ndarray
]) – The confidence (probability) of the label, should be a floating-point number between 0 and 1.