Fix zero-mask plotting bug (#16588)

This commit is contained in:
Glenn Jocher 2024-10-01 13:29:51 +02:00 committed by GitHub
parent 5af8a5c0fb
commit 7382984474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)