So i'm doing a little personal project but i keep getting this error when I try to create the recognizer. i have opencv-contrib and everything. Does anyone know whats going on? code posted below
import cv2, os
import numpy as np
from PIL import Image
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath)
recognizer = cv2.face.createLBPHFaceRecognizer()
it gets caught on that last line. I've tried reinstalling all modules already. Not really sure what else to do. The weird thing is it works on my laptop but not my desktop. They both have the same modules, same python release and running the exact same code.
Had the same problem. Use:
It worked for my program.
I fixed this issue with two commands:
First:
sudo pip3 uninstall opencv-contrib-python
Second:
sudo python3 -m pip install opencv-contrib-python==3.3.0.9
This fixed my issues. Hope it helps somebody! Also, if you are using python2, replace “pip3” with “pip” and “python3” with “python”
Even I had this problem when I ran the code using Jupyter Notebook. If you are running it on Jupyter Notebook , then download it as pyhton(.py) file and try to run it in Anaconda Prompt or Command Prompt. This solved the problem for me. Thank You.
Under Windows 7, I was able to resolve the issue by simply uninstalling and re-installing opencv:
The recogniser is called by:
I fixed this issue by installing:
sudo pip install opencv-contrib-python
.Then look for correct format.
Basically the problem is that python3 and python2 have different format of code.
recognizer = cv2.face.LBPHFaceRecognizer_create()
This is the format of python2.
recognizer = cv2.face.createLBPHFaceRecognizer()
This is the format of python3
open cmd , then --> pip install opencv-contrib-python