赞
踩
#!/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()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。