AttributeError:模块'cv2.cv2'在OpenCV中没有属性'faces'

时间:2019-04-08 20:18:31

标签: python-3.x opencv face-recognition

在参考了一些堆栈溢出答案之后,我做了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'

1 个答案:

答案 0 :(得分:1)

尝试通过以下方式更新OpenCV

pip install opencv-contrib-python