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

前端 未结 12 798
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 04:28

I am facing some attribute error while running face recognizing the code. My face detects code run perfectly.But while I try to run the face recognizing code it shows some a

相关标签:
12条回答
  • 2020-11-30 05:10

    I got openCV installed smoothly in my mac by:

    $ brew install opencv
    $ brew link --overwrite --dry-run opencv // to force linking
    $ pip3 install opencv-contrib-python
    

    I got it at windows 10 using:

    c:\> pip3 install opencv-python
    c:\> pip3 install opencv-contrib-python
    

    Then I got it tested by

    $ python3
    Python 3.7.3 (default, Mar 27 2019, 09:23:15) 
    [Clang 10.0.1 (clang-1001.0.46.3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cv2
    >>> cv2.__version__
    '4.1.0'
    >>> exit()
    
    0 讨论(0)
  • 2020-11-30 05:10

    I had a similar problem:

    module cv2 has no attribute "cv2.TrackerCSRT_create"

    My Python version is 3.8.0 under Windows 10. The problem was the opencv version installation.

    So I fixed this way (cmd prompt with administrator privileges):

    1. Uninstalled opencv-python: pip uninstall opencv-python
    2. Installed only opencv-contrib-python: pip install opencv-contrib-python

    Anyway you can read the following guide:

    https://github.com/skvark/opencv-python

    0 讨论(0)
  • 2020-11-30 05:13

    RESTART YOUR IDE

    I tried all of the different things but nothing seems to be working then I just restarted my IDE and it worked like charm.

    Still, if it does not work then try restarting your system.

    FYI, I am working on the following versions

    opencv-contrib-python==4.4.0.46
    opencv-python==4.1.2.30
    
    0 讨论(0)
  • 2020-11-30 05:13

    Check your OpenCV version

    import cv2
    cv2.__version__
    

    If your are running Python v3.x and OpenCV v4 and above:

    pip install opencv-contrib-python
    

    Try running your program again. This should now work.

    0 讨论(0)
  • 2020-11-30 05:14

    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.

    0 讨论(0)
  • 2020-11-30 05:16

    For me changing createLBPHFaceRecognizer() to

    recognizer = cv2.face.LBPHFaceRecognizer_create()
    

    fixed the problem

    0 讨论(0)
提交回复
热议问题