import cv2
face = cv2.CascadeClassifier(r'E:\net\haarcascade_frontalface_default.xml')
video = cv2.VideoCapture(0) ##读取摄像头
while video.isOpened():
if video.isOpened():
ret ,frame = video.read()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
frames = face.detectMultiScale(frame,1.3,2)
for x,y,w,h in frames:
frame = cv2.rectangle(frame , (x,y) , (x+w, y+h),(255,255,0),2)
cv2.imshow('frame',frame)
cv2.waitKey(1)
if cv2.waitKey(1) & 0xff == ord('q'):
cv2.destroyAllWindows()
video.release()
人脸检测,级联检测
最新推荐文章于 2024-07-11 15:43:52 发布