利用 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)