def face_train_video(train_path,subject,max_train,stream):
cap = cv2.VideoCapture(stream)
ret=True
ctr = 0
# minimum 10 frames/images per video
while(ctr < max_train):
# read till end of frames
ret, img = cap.read()
if not ret:
break
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow("Recognizing Face", img)
cv2.waitKey(10)
cv2.imwrite( join(train_path,subject)+ "." + str(ctr) +".jpg",img) # writes image to disk
ctr = ctr + 1
cap.release()
cv2.destroyAllWindows()
# predict live feed
评论列表
文章目录