当前位置:   article > 正文

mediapipe三维人脸检测_mediapipe 面部方向

mediapipe 面部方向
#!/usr/bin/env python3
# encoding: utf-8
#三维人脸检测
#脸上全部都是白色点
import cv2
import mediapipe as mp


mp_drawing = mp.solutions.drawing_utils
mp_face_mesh = mp.solutions.face_mesh


drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)
cap = cv2.VideoCapture(0)


with mp_face_mesh.FaceMesh(
    max_num_faces=1,
    min_detection_confidence=0.5,
    min_tracking_confidence=0.5) as face_mesh:
  while cap.isOpened():
    success, image = cap.read()
    if not success:
      print("Ignoring empty camera frame.")
      continue

    image.flags.writeable = False
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    results = face_mesh.process(image)
    image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
    # Draw the face mesh annotations on the image.
    image.flags.writeable = True
    if results.multi_face_landmarks:
      for face_landmarks in results.multi_face_landmarks:
         mp_drawing.draw_landmarks(
            image=image,
            landmark_list=face_landmarks,
            landmark_drawing_spec=drawing_spec)

    # Flip the image horizontally for a selfie-view display.
    cv2.imshow('Frame', image)
    key = cv2.waitKey(1)
    if key != -1: 
        break

cap.release()
cv2.destroyAllWindows()
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/906149
推荐阅读
相关标签
  

闽ICP备14008679号