OpenCV: AttributeError: module 'cv2' has no attribute 'face'

后端 未结 7 1796
刺人心
刺人心 2020-12-21 12:14

I am creating a face recognition system using Python and OpenCV on these versions:

  • Python 3.6.2 :: Anaconda custom (64-bit)
  • Anaconda 4.3.23
  • O
相关标签:
7条回答
  • 2020-12-21 12:25

    While I was looking for the same solution, I tried out many methods which don't work well with successfully installing OpenCV along with the extra modules i.e., OpenCV Contrib.

    Apparently, while using pip install opencv-python windows platforms usually download only OpenCV without the extra modules!

    What works, is stable and easy to install:

    1. Download the integrated 'whl' file containing both OpenCV and it's Contrib files, which would be like 'opencv_python‑3.4.3+contrib‑cp36‑cp36m‑win_amd64.whl' which can be downloaded from here.
    2. Install using pip install <whl filename>

    I have tried other methods which are unreliable such as the solution suggested by @RoyaumeIX, however ended up with failure.

    So is it with using

    pip install opencv
    pip install opencv-contrib
    

    Installing opencv-contrib does not properly register the opencv package.

    I strongly suggest that you directly download the official whl file and install it.

    0 讨论(0)
  • 2020-12-21 12:26

    The Menpo project does not have an installer for OpenCV 3.3. The Menpo project is up to 3.1 on macOS and Windows, and 3.2 on Linux. See the Anaconda package for that description and also the list of files for the installer versions. Actually, you can check out the GitHub repo for Menpo's OpenCV3 build and grab the files yourself. You can change the build files to suit your system if needed.

    I'm not sure if your pip attempt includes a typo or not---the correct PyPI package wheel file with the contrib module is opencv_contrib_python not opencv_python+contrib, as shown at PyPI. Note that if you're not using Windows the GUI features of OpenCV will not work with the pip installer, including imshow() and other similar features.

    You'd be better served just removing and reinstalling fresh with the contrib modules instead of trying to build them in later.

    0 讨论(0)
  • 2020-12-21 12:28

    I also had same problem but it got resolved by following these steps:

    1. start anaconda navigator

    2. open CMD.exe prompt, hope you see this **(base) C:\Users\acer>** this may be different for you

    3. write these command >>>**pip install opencv-contrib-python**

    4. Now you can run your code as check!! I have runned my code in Spyder in base enviroment and it worked for me!

    0 讨论(0)
  • 2020-12-21 12:29

    I found the solution to my issue, you have to follow this tutorial OpenCV with extra modules.

    The essential steps are:

    • Go to C:/PythonXX/lib/site-packeges (the site-packages folder where your python is installed), and delete cv2.pyd if present.
    • Download OpenCV with extra modules
    • Create a Visual Studio project with CMake
    • Open Python IDLE and enter import cv2. If there is no error, then the installation is successful.
    0 讨论(0)
  • 2020-12-21 12:39

    my using python 2.7 and opencv 3.3.0 working in code

    cv2.face.LBPHFaceRecognizer_create(); 
    
    0 讨论(0)
  • 2020-12-21 12:41

    this should fix the problem

    pip install opencv-python-headless
    pip install opencv-contrib-python-headless
    
    0 讨论(0)
提交回复
热议问题