人脸抓拍
作者:互联网
'''
人脸抓拍 by 郑瑞国
FaceSnapping.py
'''
import cv2
faceCascad = cv2.CascadeClassifier("C:/opencv/sources/data/haarcascades/haarcascade_frontalface_default.xml")
cap=cv2.VideoCapture(0)
while(1):
ret,frame=cap.read()
#gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces = faceCascad.detectMultiScale(frame,1.3,5)
for (x,y,w,h) in faces:
frame = cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)
cv2.putText(frame,'Face',(x,y-7), 3, 1.2, (0, 255, 0), 2, cv2.LINE_AA)
cv2.imshow('face',frame)
cv2.waitKey(0)
cv2.imwrite('c:/python37/AICode/face'+str(x)+str(y)+str(w)+str(h)+'.jpg',frame)
cv2.imshow('face',frame)
cv2.waitKey(1)
cap.release()
cv2.destroyAllWindows()
标签:抓拍,frame,cap,cv2,face,人脸,str,255 来源: https://blog.csdn.net/zheng_ruiguo/article/details/88533595