You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
607 B
25 lines
607 B
def Train_new_face():
|
|
print("\n正在训练")
|
|
# cv2.destroyAllWindows()
|
|
path = 'data'
|
|
|
|
# 初始化识别的方法
|
|
recog = recognizer
|
|
|
|
# 调用函数并将数据喂给识别器训练
|
|
faces, ids = get_images_and_labels(path)
|
|
print('本次用于训练的识别码为:') # 调试信息
|
|
print(ids) # 输出识别码
|
|
|
|
# 训练模型 #将输入的所有图片转成四维数组
|
|
recog.train(faces, np.array(ids))
|
|
# 保存模型
|
|
|
|
yml = str(Total_face_num) + ".yml"
|
|
rec_f = open(yml, "w+")
|
|
rec_f.close()
|
|
recog.save(yml)
|
|
|
|
# recog.save('aaa.yml')
|
|
|