基于mediapipe的人脸关键点检测及嘴唇换色demo

 Face-mesh(人脸关键点检测及网格绘制)

基于mediapipe的人脸关键点检测及嘴唇换色demo_第1张图片

import mediapipe as mp
import numpy as np
import cv2

mp_face_mesh = mp.solutions.face_mesh
face_mesh = mp_face_mesh.FaceMesh(static_image_mode=False, # False处理视频,True处理单张图片
                                  max_num_faces=1,
                                  refine_landmarks=True,
                                  min_detection_confidence=0.5,
                                  min_tracking_confidence=0.5) # 静态图片不用设置

# 构建绘图对象
mp_drawing = mp.solutions.drawing_utils
mp_drawing_styles = mp.solutions.drawing_styles


# 开启摄像头
cap = cv2.VideoCapture(0)
while True:
    # 读取一帧图像
    ret, img = cap.read()
    height, width, channels = np.shape(img)
    img_RGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

    # 特征点提取
    results = face_mesh.p

你可能感兴趣的:(pytorch,tensorflow,mediapipe,人脸关键点检测,face-mesh,嘴唇换色)