AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer' - python

From this question in SO I understand the error should be solved by having opencv contrib, but the thing is that when I first built opencv using cmake using this guide by pyimagesearch , I had also built opencvcontrib. If I must rebuild it, how exactly should I do it?
This is the error:
import cv2
cv2.createLBPHFaceRecognizer()
Traceback (most recent call last):
File "stdin", line 1, in module
AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'
Also:
import cv2
help(cv2.face.createLBPHFaceRecognizer)
Traceback (most recent call last):
File "stdin", line 1, in module
AttributeError: 'module' object has no attribute 'face'
Mac OS, Python 2.7, Opencv 3.2

After searching high and low, I found that using cv2.face.LBPHFaceRecognizer_create() just do the trick for opencv 3.3.0 with opencv contrib. Hope you find it useful.

createLBPHFaceRecognizer() is in the sub-module cv2.face in python. To access it you should use cv2.face.createLBPHFaceRecognizer().

I have executed this command: pip install opencv-contrib-python
it has install opencv version : 3.4.0,
and it works with this formula:
import cv2
recognizer = cv2.face.LBPHFaceRecognizer_create()

Related

AttributeError: partially initialized module 'face_recognition' has no attribute 'face_encodings'

I am trying to make face recognition script in python with the help of below given link found on google.
https://www.mygreatlearning.com/blog/face-recognition/
I have installed:
OpenCV
dlib and
face_recognition
libraries.
Also, installed Visual C++ for CMake.
And now I am trying to "extract features from Face" using code given in above link.
While running script, I am getting below error:
Traceback (most recent call last):
File "C:\Users\ajay.arora2\AppData\Local\Programs\Python\Python38-32\extract_features_from_face.py", line 2, in <module>
import face_recognition
File "C:\Users\ajay.arora2\AppData\Local\Programs\Python\Python38-32\face_recognition.py", line 32, in <module>
encodings = face_recognition.face_encodings(rgb)
AttributeError: partially initialized module 'face_recognition' has no attribute 'face_encodings' (most likely due to a circular import)
I have tried re-installing face_recognition module.
Please suggest any workaround.
Thanks in advance.
Most probably you have named your file the same as the library "face_recognition".
Circular import happens when you want to import something from the same file.

module object has no attribute imread and imshow

I have installed OpenCV in Python 3.6(64 bit), but whenever I compile the below code, it is throwing an error of module object has no attribute imread and imshow.
This happens while doing in the python idle but when trying in the command-line interpreter with windows 10 it is working. Moreover while getting opencv version, the command-line code is working but not with idle.
Please give the possible solution for this problem.
Python IDLE:
import numpy as np
import cv2
img = cv2.imread("H:\python project\watch.jpg",0)
cv2.imshow("image",img)
python IDLE error msg:
Traceback (most recent call last):
File "H:\python project\cv2.py", line 3, in <module>
import cv2
File "H:\python project\cv2.py", line 5, in <module>
img = cv2.imread("H:\python project\watch.jpg",0)
AttributeError: module 'cv2' has no attribute 'imread'
Try to import cv2 package in command line. If it executes without any error than it should work.
Have you pasted the cv2.pyd file in lib/site-packages folder?

Zbar on raspberry?

I'm trying use zbar on RPI3 but i have a problem. I dont have ImageScanner, Image... module.
import zbar
scanner = zbar.ImageScanner()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageScanner'
I tried to install it from pip, official repository, some fork, but nothing work.
https://pastebin.com/ajbWdSct
how can i access image modul?
To list module content try to type:
import zbar
dir(zbar)
See example are in source https://github.com/npinchot/zbar/blob/master/examples/read_one.py

Python tensorflow error, sys has no attribute getdlflags

I Just attempted to install tensorflow for python and when I went to the console to see if the init.py was working it returned this error. I installed it manualy without pip or any other package manager.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\*username\AppData\Local\Programs\Python\Python35-32\lib\tensorflow\__init__.py", line 43, in <module>
_default_dlopen_flags = sys.getdlopenflags()
AttributeError: module 'sys' has no attribute 'getdlopenflags'
TensorFlow is not supported on Windows yet. Please follow this github issue which tracks TensorFlow Windows support.

Python's AttributeError: 'module' object has no attribute 'require_version'

I am using Python3.4. I am trying to open an application which supposedly uses Python and can't seem to get it working. I do receive the following error:
Traceback (most recent call last):
File "pychess", line 24, in <module>
gi.require_version("Gtk", "3.0")
AttributeError: 'module' object has no attribute 'require_version'
Install the dependency with pip install PyGTK, as João Cartucho suggests.

Categories

Resources