from skimage import io,color
import dlib
from skimage.feature import hog
import matplotlib.pyplot as plt
image=io.imread(r"C:\Users\hp\Desktop\FaceDetection\eg.png")
image=color.rgb2gray(image)
array,hog_image=hog(image,visualise=True)
fig,(ax1,ax2)=plt.subplots(1,2,figsize=(8,4))
ax1.imshow(image,cmap=plt.cm.gray)
ax2.imshow(hog_image,cmap=plt.cm.gray)
plt.show()
图中人脸加框
from skimage import io
import dlib
file_name="li_00.jpg"
image=io.imread(file_name)
detector=dlib.get_frontal_face_detector()
detector_faces=detector(image,1)
print("发现{}张人脸,在{}图片中".format(len(detector_faces),file_name))
model="shape_predictor_68_face_landmarks.dat"
predictor=dlib.shape_predictor(model)
win=dlib.image_window()
win.set_image(image)
for i,box in enumerate(