简体   繁体   中英

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:

在此处输入图像描述

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM