AttributeError:模块"cv2.cv2"没有属性"createLBPHFaceRecognizer"

问题描述:

我在识别代码时遇到一些属性错误.我的脸部检测代码可以完美运行,但是当我尝试运行人脸识别代码时,它显示出一些属性错误.我用谷歌搜索并尝试遵循所有步骤.但是,它仍然显示相同的错误.这是我的代码:

I am facing some attribute error while running face recognizing the code. My face detects code run perfectly.But while I try to run the face recognizing code it shows some attribute error. I googled and tried to follow all the steps. But still, it shows the same error. Here is my code:

人脸识别

,我收到以下错误消息:

and I get the following error:

C:\Users\MAN\AppData\Local\Programs\Python\Python36\python.exe C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognize1.py
Traceback (most recent call last):
  File "C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognize1.py", line 4, in <module>
    recognizer = cv2.createLBPHFaceRecognizer()
AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer'

Process finished with exit code 1.

我正在使用Windows平台. python 3.6版本.谢谢.

I am using Windows platform. python 3.6 version.Thanks in advance.

您需要安装opencv-contrib

You need to install opencv-contrib

pip install opencv-contrib-python

它应该在那之后工作.