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

故事扮演 提交于 2019-11-30 12:04:37
Rick

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

Chandan Purohit

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

for python versions as 3.6 uses:

rec = cv2.face.LBPHFaceRecognizer_create();

For windows users using python 3, you can get the opencv_contrib from here. My system is 64 bit so opencv_python‑3.3.0+contrib‑cp36‑cp36m‑win_amd64.whl is what I used. If you are 32 bit then choose the 32 bit version.

Open command prompt and navigate to the download folder and use the command

pip install opencv_python-3.3.0+contrib-cp36-cp36m-win_amd64.whl

Note: Use a command similar to the file you just downloaded and make sure to uninstall an older version before installing the new one with the contrib. I had to run:

pip uninstall opencv_python-3.3.0-cp36-cp36m-win_amd64.whl

before making the new installation.

Then make sure it's successful

>>>import cv2
>>>cv2.face
<module 'cv2.face'>

Instead of createLBPHFaceRecognizer(), you must use LBPHFaceRecognizer_create()

Shubham Gupta

For Python version 3.6.x, do this:

Open your terminal and install opencv-contrib-python

python -m pip install opencv-contrib-python

when you done with it use this

recoginizer = cv2.face.LBPHFaceRecognizer_create()

For More option you can do it like this way:

print(help(cv2.face))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!