Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'cv2.cv2' has no attribute '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:

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 Windows platform. python 3.6 version.Thanks in advance.

like image 566
Manjurul Ahsan Avatar asked Jun 19 '17 14:06

Manjurul Ahsan


2 Answers

You need to install opencv-contrib

pip install opencv-contrib-python 

It should work after that.

like image 148
Željko Krnjić Avatar answered Oct 02 '22 15:10

Željko Krnjić


if you are using python3.x and opencv==4.1.0 then use following commands First of all

python -m pip install --user opencv-contrib-python 

after that use this in the python script

cv2.face.LBPHFaceRecognizer_create()  
like image 37
Priyansh gupta Avatar answered Oct 02 '22 14:10

Priyansh gupta