I have a python function with opencv 3. it works without virtual environment.Also I installed opencv on venv from:pyimagesearch. i am trying to run that python function on v
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))
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()
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
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()
for python versions as 3.6 uses:
rec = cv2.face.LBPHFaceRecognizer_create();
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()