Fix zero-mask plotting bug (#16588)
This commit is contained in:
parent
5af8a5c0fb
commit
7382984474
1 changed files with 7 additions and 4 deletions
|
|
@ -805,11 +805,14 @@ class Annotator:
|
|||
Function for drawing segmented object in bounding box shape.
|
||||
|
||||
Args:
|
||||
mask (list): masks data list for instance segmentation area plotting
|
||||
mask_color (RGB): mask foreground color
|
||||
label (str): Detection label text
|
||||
txt_color (RGB): text color
|
||||
mask (np.ndarray): A 2D array of shape (N, 2) containing the contour points of the segmented object.
|
||||
mask_color (tuple): RGB color for the contour and label background.
|
||||
label (str, optional): Text label for the object. If None, no label is drawn.
|
||||
txt_color (tuple): RGB color for the label text.
|
||||
"""
|
||||
if mask.size == 0: # no masks to plot
|
||||
return
|
||||
|
||||
cv2.polylines(self.im, [np.int32([mask])], isClosed=True, color=mask_color, thickness=2)
|
||||
text_size, _ = cv2.getTextSize(label, 0, self.sf, self.tf)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue