Skip to content

Commit 71a6ded

Browse files
committed
faster with alpha=1
1 parent 8069382 commit 71a6ded

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

patched_yolo_infer/functions_extra.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ def visualize_results_usual_yolo_inference(
123123
)
124124

125125
if fill_mask:
126-
color_mask = np.zeros_like(img)
127-
color_mask[mask_resized > 0] = color
128-
labeled_image = cv2.addWeighted(labeled_image, 1, color_mask, alpha, 0)
126+
if alpha == 1:
127+
cv2.fillPoly(labeled_image, pts=mask_contours, color=color)
128+
else:
129+
color_mask = np.zeros_like(img)
130+
color_mask[mask_resized > 0] = color
131+
labeled_image = cv2.addWeighted(labeled_image, 1, color_mask, alpha, 0)
129132

130133
cv2.drawContours(labeled_image, mask_contours, -1, color, thickness)
131134

0 commit comments

Comments
 (0)