python - 属性错误: module 'cv2.cv2' has no attribute 'faces' in OpenCV

标签 python opencv computer-vision face-recognition

在引用了一些 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

关于python - 属性错误: module 'cv2.cv2' has no attribute 'faces' in OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55581161/

相关文章:

python - 在 python 中捕获损坏的套接字

c++ - 如何在不安装的情况下将 opencv 源文件包含为 cmake 依赖项?

c++ - 图片中定义标记的位置检测

java - 如何用java在openCv中找到矩形的角点

opencv - 在 Ubuntu/Linux 上用 C++ 编译 OpenCV 代码的 Makefile

python - 使用 OpenCV 提高检测线的准确性

algorithm - Zillow 中的范围搜索

python - 使用 ftputil 上传文件时出现问题

python从id的日期范围中找到唯一的日期

python - 在 Python 中计算表达式的值