'Mask a part of the face using MediaPipe - python

I want to mask the cheek, but this mask should have curved edges and not be sharp. I drew the mask using the landmark keys:

right_cheek = [330, 350, 411, 376, 352, 345, 264] left_cheek = [101, 129, 187, 147, 123, 116, 34]

but it did not work good and the edges became sharp. I want like the picture below:

enter image description here



Solution 1:[1]

After creating the mask, you can round the edges of the mask with the following code:

mask = cv2.GaussianBlur(mask, (51, 15), 0) * 0.8
kernel = np.ones((15, 15), np.uint8)
mask = cv2.erode(mask, kernel, iterations=1)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maryam Boneh