Skip to content

Commit 9e2fbbf

Browse files
committed
new transparent mask alpha
1 parent 999ef2c commit 9e2fbbf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

patched_yolo_infer/functions_extra.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,12 @@ def visualize_results(
369369
points = np.array(polygons[i].reshape((-1, 1, 2)), dtype=np.int32)
370370
cv2.drawContours(labeled_image, [points], -1, color, thickness)
371371
if fill_mask:
372-
cv2.fillPoly(labeled_image, pts=[points], color=color)
372+
if alpha == 1:
373+
cv2.fillPoly(labeled_image, pts=[points], color=color)
374+
else:
375+
mask_from_poly = np.zeros_like(img)
376+
color_mask_from_poly = cv2.fillPoly(mask_from_poly, pts=[points], color=color)
377+
labeled_image = cv2.addWeighted(labeled_image, 1, color_mask_from_poly, alpha, 0)
373378

374379
# Write class label
375380
if show_boxes:

0 commit comments

Comments
 (0)