AttributeError: module 'cv2.cv2' does not have the attribute 'createLBPHFaceRecognizer'

I am encountering some attribute error when running a face that recognizes the code. My face recognizes the code perfectly. But while I try to run the face recognition code, it shows some attribute error. I googled and tried to follow all the steps. But still, she shows the same error. Here is my code:

face recognition

enter link description here

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. 

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

+19
source share
7 answers

You need to install opencv-contrib

 pip install opencv-contrib-python 

After that, it should work.

+49
source

Use the following

 recognizer = **cv2.face.LBPHFaceRecognizer_create()** 

After installation:

 pip install opencv-contrib-python 

If you use anaconda, then in anaconda tell me:

 conda install pip 

then

 pip install opencv-contrib-python 
+7
source

You are probably using Python3, and therefore you should use pip3 to install the opencv-contrib package:

 pip3 install opencv-contrib-python 

It worked for me.

+3
source

opencv changed some functions and moved them to opencv_contrib repo, so you need to call the mentioned method with:

 recognizer = cv2.face.createLBPHFaceRecognizer() 

Note. You can see this issue about missing documents. Try using the help function help(cv2.face.createLBPHFaceRecognizer) for more details.

+2
source

For me changing createLBPHFaceRecognizer () to

 recognizer = cv2.face.LBPHFaceRecognizer_create() 

fixed the problem

+2
source

I installed openCV on my Mac without any problems:

 $ brew install opencv $ brew link --overwrite --dry-run opencv // to force linking $ pip3 install opencv-contrib-python 

I got this on Windows 10 using:

 c:\> pip3 install opencv-python c:\> pip3 install opencv-contrib-python 

Then i checked it

 $ python3 Python 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '4.1.0' >>> exit() 
0
source

For me, I needed OpenCV (3.4.2), Py-OpenCV (3.4.2), LibOpenCV (3.4.2).

My Python was version 3.5.6 with Anaconda on Windows OS 10.

0
source

Source: https://habr.com/ru/post/1268990/


All Articles