代码实战:人脸识别
import numpy as np
import cv2
img = cv2.imread("3.webp")face_cascade = cv2.CascadeClassifier(r'./haarcascade_frontalface_default.xml')gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)#探测图片中的人脸
faces = face_cascade.detectMultiScale(gray,scaleFactor=1.2,minNeighbors=3,minSize=(10, 10),flags=cv2.CASCADE_SCALE_IMAGE
)#框出人脸
for (x, y, w, h) in faces:cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), 2)cv2.imshow("Image", img)
cv2.waitKey(0)
xml文件是已经训练好的脸部特征和参数
杨幂的这个效果不错
詹姆斯怎么手环也被识别了?