AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer'

You need to install opencv-contrib

pip install opencv-contrib-python

It should work after that.


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() 

You might be running Python3 and therefore you are supposed to use pip3 to install the opencv-contrib package :

pip3 install opencv-contrib-python

This worked for me.


Use the following

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

After you install:

pip install opencv-contrib-python

If using anaconda then in anaconda prompt:

conda install pip

then

pip install opencv-contrib-python

opencv has changed some functions and moved them to their opencv_contrib repo so you have to call the mentioned method with:

recognizer = cv2.face.createLBPHFaceRecognizer()

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