![](/img/trans.png)
[英]AttributeError: module 'cv2.cv2' has no attribute 'freetype' 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.