Opencv3 and Python 2.7 on Virtual Environment - AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'

From OpenCV 3, you have to get and build the opencv_contrib repo. Then you can use the submodule "face".

Help on module cv2.face in cv2:

NAME
    cv2.face

FILE
    (built-in)

FUNCTIONS
    createEigenFaceRecognizer(...)
        createEigenFaceRecognizer([, num_components[, threshold]]) -> retval

    createFisherFaceRecognizer(...)
        createFisherFaceRecognizer([, num_components[, threshold]]) -> retval

    createLBPHFaceRecognizer(...)
        createLBPHFaceRecognizer([, radius[, neighbors[, grid_x[, grid_y[, threshold]]]]]) -> retval

Voila~ You can now use cv2.face.createLBPHFaceRecognizer()


The easiest way for me was to use anaconda package:

conda install -c menpo opencv3=3.1.0

Once installed, use cv2.face.createLBPHFaceRecognizer() or other face recognizers. Hope this helps


try this

run this command to install the contrib

python -m pip install opencv-contrib-python

after this is done use this attribute

recoginizer = cv2.face.LBPHFaceRecognizer_create()