AttributeError: module 'cv2.cv2' has no attribute 'faces' in OpenCV
AttributeError: module 'cv2.cv2' has no attribute 'faces' in OpenCV
在参考了我所做的一些 Stack Overflow 答案后 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'
尝试使用
更新 OpenCV
pip install opencv-contrib-python
在参考了我所做的一些 Stack Overflow 答案后 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'
尝试使用
更新 OpenCVpip install opencv-contrib-python