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.
我是一名优秀的程序员,十分优秀!