在参考了一些堆栈溢出答案之后,我做了pip install opencv-contrib
,但仍然遇到这些错误。
培训代码:
face_recognizer=cv2.face.LBPHFaceRecognizer_create()
用于面部检测的代码:
faces,faceID = fr.labels_for_training_data('C:\\Users\\Desktop\\python tests\\0')
face_recognizer=fr.train_classifier(faces,faceID)
face_recognizer.save('C:\\Users\\Desktop\\python tests\\trainingData.yml')
错误是:
File "C:/Users/vsneh/OneDrive/Desktop/python tests/Face_detect_Tester.py", line 15, in <module>
face_recognizer=fr.train_classifier(faces,faceID)
File "C:/Users/vsneh/OneDrive/Desktop/python tests\faceRecognition.py", line 47, in train_classifier
face_recognizer=cv2.faces.LBPHFaceRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'faces'
答案 0 :(得分:1)
尝试通过以下方式更新OpenCV
pip install opencv-contrib-python