opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
75.95k stars 55.62k forks source link

module 'cv2.cv2' has no attribute 'face' #13848

Closed serome111 closed 5 years ago

serome111 commented 5 years ago
Detailed description

when I execute it tells me module 'cv2.cv2' has no attribute 'face'

Steps to reproduce

the error occurs when I use the following line reconocimiento = cv2.face.createLBPHFaceRecognizer()

I've tried installing

pip3 install opencv-contrib-python

i put pip3 freeze

appnope==0.1.0 backcall==0.1.0 decorator==4.3.0 ipykernel==4.8.2 ipython==6.5.0 ipython-genutils==0.2.0 jedi==0.12.1 jupyter-client==5.2.3 jupyter-core==4.4.0 nltk==3.4 numpy==1.15.4 opencv-contrib-python==4.0.0.21 opencv-python==4.0.0.21 pandas==0.23.4 parso==0.3.1 pexpect==4.6.0 pickleshare==0.7.4 Pillow==5.4.1 prompt-toolkit==1.0.15 ptyprocess==0.6.0 Pygments==2.2.0 python-dateutil==2.7.3 pytz==2018.7 pyzmq==17.1.0 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.11.0 tornado==5.1 traitlets==4.3.2 virtualenv==16.0.0 wcwidth==0.1.7

I've read some solutions and I've already tried

reconocimiento = cv2.face.LBPHFaceRecognizer_create() .
reconocimiento = cv2.face.createLBPHFaceRecognizer() reconocimiento = cv2.face.createLBPHFaceRecognizer()

but it doesn't work. He tells me he hasn't found the attribute 'face' yet.

how to add the 'face' attribute?

image image

MLNoises commented 5 years ago

Hey have you found the solution cause I ve same as you

serome111 commented 5 years ago

No, I don't have the solution yet, but if you find it, please share it with me.

santoshkrishnanr commented 5 years ago

even i have the same problem. but try uninstalling it by

pip uninstall opencv_contrib_python and install again pip install opencv_contrib_python

serome111 commented 5 years ago

Incluso tengo el mismo problema. pero intenta desinstalarlo por

pip desinstala opencv_contrib_python e instala de nuevo pip instala opencv_contrib_python

I tried, but the mistake persists.

santoshkrishnanr commented 5 years ago

recognizer=cv2.face.EigenFaceRecognizer_create() try this

santoshkrishnanr commented 5 years ago

print(help(cv2.face))

hritik5102 commented 4 years ago

those who got an error like this :

recognizer = cv2.face.LBPHFaceRecognizer_create() AttributeError: module 'cv2.cv2' has no attribute 'face'

Solution :

1) print(dir (cv2.face)) //on python shell 2) recognizer = cv2.face.LBPHFaceRecognizer_create()

Klatuu82 commented 4 years ago

those who got an error like this :

recognizer = cv2.face.LBPHFaceRecognizer_create() AttributeError: module 'cv2.cv2' has no attribute 'face'

Solution :

  1. print(dir (cv2.face)) //on python shell
  2. recognizer = cv2.face.LBPHFaceRecognizer_create()

nope that dosnt work

zeus7678 commented 4 years ago

write pip install opencv-contrib-python --upgrade if gives error then write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create();

puthusseri commented 4 years ago
  1. print(dir (cv2.face))

Find the exact name of the function from the directory and choose that

savindu4161 commented 4 years ago

problem comes with the new versions of opencv. need a solution for that....

ibharatsaini commented 4 years ago

first uninstall opencv-python -pip uninstall opencv-python then install opencv-contrib-python -pip install opencv-contrib-python

pb1981 commented 4 years ago

I have faced same problem 'cv2.cv2' has no attribute 'face'

Only installing below didn't solve the problem for me. $pip install opencv-contrib-python

but when upgraded it solved the problem for me. $pip install opencv-contrib-python --upgrade

Bavalpreet commented 4 years ago

nothing is working

rishabh8687 commented 4 years ago

try this it works for me write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create()

sukanyabudaraju commented 4 years ago

try this it works for me write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create()

thank you.its working

moisesmartins14-zz commented 4 years ago

anyone with error even intalating opencv-contrib-python use VScode, was using pycharm when I switched to vscode worked.

PyCharm pycharm

VSCode vscode

alalek commented 4 years ago

Use dumping of cv.__file__ and sys.path for investigation of configuration problems (misconfigured build environments can't be fixed from OpenCV side).

KritiShahi commented 4 years ago

anyone with error even intalating opencv-contrib-python use VScode, was using pycharm when I switched to vscode worked. PyCharm

VSCode

I followed your steps it worked for me but I wanted to use PyCharm IDE only so I found the solution for this to work on PyCharm IDE. Install the package opencv-contrib-python in the same way as we install opencv package on Pycharm IDE. Go to Settings, click on the plus sign. Available packages dialog box will open and type opencv-contrib-python and click on install package.

Michael07220823 commented 4 years ago

I try the two kind of opencv-contrib-python, and two kind version can run successful.

Enviorment: Windows 10 Pro VSCode: 1.41.0 python: 3.6.6 opencv-contrib-python: 4.0.0.21、4.1.2.30

Command: pip install --force-reinstall opencv-contrib-python==4.1.2.30 pip install --no-cache --force-reinstall opencv-contrib-python==4.0.0.21

Hariprasad-UP commented 4 years ago

try this it works for me write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create()

thank you.its working

snehitvaddi commented 4 years ago

python -m pip install --user opencv-contrib-python After doing this, if you are using OpenCV == 4.* then Restart your system then use cv2.face.LBPHFaceRecognizer_create()

90% of the time this method should solve the problem.

karthi-OSCP commented 4 years ago

hey guys found the solution pip install opencv-contrib-python==3.4.7.28 try like this we have to specifically say the version try lesser version mine was 4.x so I did and no error popped up

LaurentBerger commented 4 years ago

opencv_contrib-python is the C++ binding of opencv and opencv_contrib libs opencv-python is the C++ binding of opencv lib

You must not install opencv-python if you want to use opencv_contrib-python

Read doc https://pypi.org/project/opencv-contrib-python/ :

Installation and Usage

If you have previous/other manually installed (= not installed via pip) version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts.

Hariprasad-UP commented 4 years ago

Thank You Sir

On Tue, 4 Feb 2020 at 13:49, LaurentBerger notifications@github.com wrote:

opencv_contrib-python is the C++ binding of opencv and opencv_contrib libs opencv-python is the C++ binding of opencv lib

You must not install opencv-python if you want to use opencv_contrib-python

Read doc https://pypi.org/project/opencv-contrib-python/ : Installation and Usage If you have previous/other manually installed (= not installed via pip) version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/opencv/opencv/issues/13848?email_source=notifications&email_token=ANAEPG5QBZWIDHFNH6SRQR3RBEQKFA5CNFSM4GX4CPWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKWXKBA#issuecomment-581793028, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANAEPG65QM5CPA7Y5B3HXZ3RBEQKFANCNFSM4GX4CPWA .

k-acme commented 4 years ago

For raspberry pi 3B try this:

sarojkumar007 commented 4 years ago

recognizer=cv2.face.EigenFaceRecognizer_create() try this

The problem is cv2.cv2 has no attribute face, using EigenFaceRecognizer_create() does not provide a solution.

YingjieQiao commented 4 years ago

I try the two kind of opencv-contrib-python, and two kind version can run successful.

Enviorment: Windows 10 Pro VSCode: 1.41.0 python: 3.6.6 opencv-contrib-python: 4.0.0.21、4.1.2.30

Command: pip install --force-reinstall opencv-contrib-python==4.1.2.30 pip install --no-cache --force-reinstall opencv-contrib-python==4.0.0.21

Thank you this solved my problem!

Ok so in case anyone run into the same problem:

I was using opencv 4.2 version on Mac, and it gives me

qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: cocoa, minimal, offscreen.

Installing back to version 4.1 solves this "platform" problem but it gives out the 'cv2.cv2' has no attribute 'face' as described in the issue. And simply pip installopencv-contrib-python does not sovle this problem. Have to use pip install --force-reinstall opencv-contrib-python==4.1.2.30 to solve it.

Thanks once again!

mishradeva96 commented 4 years ago
  1. print(dir (cv2.face))

Find the exact name of the function from the directory and choose that

foolish person

TiwaPhil commented 4 years ago

write pip install opencv-contrib-python --upgrade if gives error then write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create(); this works perfectly for me:pip install opencv-contrib-python --user

TiwaPhil commented 4 years ago

write pip install opencv-contrib-python --upgrade if gives error then write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create(); this works perfectly for me:pip install opencv-contrib-python --user
thanks a lot

amrute commented 4 years ago

try this it works for me write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create()

thank you.its working

Perfect... This is the best answer. Worked well!!

Jiya-Ull-Haq commented 4 years ago

anyone with error even intalating opencv-contrib-python use VScode, was using pycharm when I switched to vscode worked.

PyCharm pycharm

VSCode vscode

Your are using system library there. That means you have perfect version of opencv in your system library. If the code has to run in pycharm then do the following steps: go to file | settings | project interpreter | then remove opencv-python (if installed already) | while installing opencv-python check the "specify version" box then install the lower version.. This should work because there is a bug in the current version of opencv...

peetio commented 4 years ago

You can solve this problem by deleting everything on your computer related to OPENCV,. If you are using pycharm go to settings -> Project Interpreter and delete all the opencv related packages. Then to pip install opencv-contrib-python.

This worked for me after 2 days of searching the web.

The opencv-contrib consists of contrib modules and face is one of them, but it will not work if you already have the main modules of opencv installed.

Sourabhb-nd commented 4 years ago

I have faced same problem 'cv2.cv2' has no attribute 'face'

Only installing below didn't solve the problem for me. $pip install opencv-contrib-python

but when upgraded it solved the problem for me. $pip install opencv-contrib-python --upgrade

This solved the problem. Thank you.

Georgian-LalitKumar commented 4 years ago

I try the two kind of opencv-contrib-python, and two kind version can run successful.

Enviorment: Windows 10 Pro VSCode: 1.41.0 python: 3.6.6 opencv-contrib-python: 4.0.0.21、4.1.2.30

Command: pip install --force-reinstall opencv-contrib-python==4.1.2.30 pip install --no-cache --force-reinstall opencv-contrib-python==4.0.0.21 this worked for me ,thanks

Shoaib0023 commented 4 years ago

try this it works for me write pip install opencv-contrib-python --user it will work fine for cv2.face.LBPHFaceRecognizer_create()

thank you.its working

works for me also .