如何用新的附加图片训练人脸识别器?

how to train a face-recognizer with new additional pictures?

recognizer= cv2.face.createLBPHFaceRecognizer()
if os.path.exists("recognizer\trainingData_LBPHF.yml"):
    recognizer.load("recognizer\trainingData_LBPHF.yml")
IDs,faces=retrainer(directory)
recognizer.train(faces,IDs)

当我 运行 编写此代码时,我的识别器会在新图片上重新训练,但会丢失之前完成的所有操作。有没有一种方法可以在新的附加图片上重新训练我的识别器,而不用在旧图片上重新训练以加速处理?

您需要致电update:

recognizer.update(faces, IDs)

This method updates a (probably trained) FaceRecognizer, but only if the algorithm supports it. The Local Binary Patterns Histograms (LBPH) recognizer (see createLBPHFaceRecognizer) can be updated.