#pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python # 脸部检测,只显示六个点 # 两只眼睛,嘴巴,鼻子,左右两侧的颧骨 import cv2 import mediapipe mp_face_detection = mediapipe.solutions.face_detection mp_drawing = mediapipe.solutions.drawing_utils cap = cv2.VideoCapture(0) with mp_face_detection.FaceDetection(min_detection_confidence=0.5) as face_detection: 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_detection.process(image) image.flags.writeable = True image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) if results.detections: for detection in results.detections: mp_drawing.draw_detection(image, detection) cv2.imshow('Frame', image) key = cv2.waitKey(1) if key != -1: break cap.release() cv2.destroyAllWindows()
mediapipe简单的人脸检测
最新推荐文章于 2024-05-13 10:10:11 发布