10 percent speed up and no ver

This commit is contained in:
kapter committed 2023-10-06 10:58:43 +03:00
1 parent 5aaa15c894
commit d2fe2ad40c
1 file changed
+4 -9
+4 -9
View File
@@ -94,8 +94,7 @@ class MaskAnnotator(BaseAnnotator):
self,
color: Union[Color, ColorPalette] = ColorPalette.default(),
opacity: float = 0.5,
color_map: str = "class",
ver: str = "v1",
color_map: str = "class"
):
"""
Args:
@@ -151,14 +150,10 @@ class MaskAnnotator(BaseAnnotator):
colored_mask = np.zeros_like(scene, dtype=np.uint8)
color_bgr = color.as_bgr()
colored_mask[:] = color_bgr
colored_scene = cv2.addWeighted(
scene[mask] = cv2.addWeighted(
colored_mask, self.opacity, scene, 1 - self.opacity, 0
)
empty = np.zeros((mask.shape[0], mask.shape[1], 1), dtype=np.uint8)
empty[mask] = 255
scene = cv2.bitwise_and(scene, scene, mask=cv2.bitwise_not(empty))
top = cv2.bitwise_and(colored_scene, colored_scene, mask=empty)
scene = cv2.add(top, scene)
)[mask]
return scene