如何將人臉變漂亮(一)

利用 mediapipe 進行處理
規劃
1.先把人臉辨識,然後取出框框
2.把框框內的人臉,進行美容
-高反差保留
(1)曝光度調整
(2)綠色與藍色,疊加
(3)YUCIHighPassSkinSmoothingMaskBoost
-調整圖像亮度
-混合
3.把人臉的嘴巴,進行塗紅
4.把人臉的眼睛塗黑

先畫畫框
import cv2
import mediapipe

img = cv2.imread(“./images/person.jpg”)

mp_face_detection = mediapipe.solutions.face_detection
face_detector = mp_face_detection.FaceDetection( min_detection_confidence = 0.6)
results = face_detector.process(img)
if results.detections:
for face in results.detections:
confidence = face.score
bounding_box = face.location_data.relative_bounding_box

    x = int(bounding_box.xmin * img.shape[1])
    w = int(bounding_box.width * img.shape[1])
    y = int(bounding_box.ymin * img.shape[0])
    h = int(bounding_box.height * img.shape[0])
    y = y - int(h/4)
    h = h + int(h/4) 
    img_face=img[y:y+h,x:x+w]           
    cv2.rectangle(img, (x, y), (x + w, y + h), (255, 255, 255), thickness = 2)

plt.figure(figsize=(16,16))
plt.subplot(131)
plt.imshow(img[:,:,::-1])
plt.axis(‘off’)
plt.figure(figsize=(5,5))
plt.subplot(132)
plt.imshow(img_face[:,:,::-1])
plt.axis(‘off’)
plt.imsave(‘light_img.jpg’,tc_img)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值