第三节
import cv2
import dlib
import matplotlib.pyplot as plt
path = "/Users/liushuhan/Desktop/opencv/zls.jpg"
img = cv2.imread(path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(r"/Users/liushuhan/opt/anaconda3/lib/python3.9/site-packages/face_recognition_models/models/shape_predictor_5_face_landmarks.dat")
dets = detector(gray, 1)
for face in dets:
shape = predictor(img, face)
for pt in shape.parts():
pt_pos = (pt.x, pt.y)
img=cv2.circle(img, pt_pos, 2, (0, 255, 0), 10)
plt.imshow(img)
plt.axis('off')
plt.show()
#识别人脸找到五官
import cv2
import dlib
import matplotlib.pyplot as plt
path = "/Users/liushuhan/Desktop/opencv/zls.jpg"
img = cv2.imread(path)
gray = cv2.cvtColor(i