0

I am trying to use LBPHfacerecognizer in my python3.6 code.

recognizer = cv2.face.createLBPHFaceRecognizer()

I am aware that face module is in opencv_contrib module. I even uninstalled openCV and installed again with contrib module. I compiled OpenCV with it and python still gives an error which is:

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

Although in opencv/build/lib I have libopencv_face.dylib, it doesn't compile with python3 and opencv.

I tried everything I can think of but I am running out of ideas.

Any ideas?

edit: Python doesn't give an error when I am working under python3 environment anymore but I still have the same error when I try to run my code in the terminal.

What I am trying to run:

python3 main.py

Any ideas why I have this problem or how I can fix it?

4

2 回答 2

0

识别器 = cv2.createLBPHFaceRecognizer();

这对我来说是错误的, 我尝试过,只需在此处查看图像。

试试下面的代码,它可能会给你结果。

识别器 = cv2.face.LBPHFaceRecognizer_create();

于 2017-12-29T09:15:08.083 回答
0

首先,我的第一个错误是在做了几次cmake之后,我没有删除旧的cv2.so文件并用新的cv2.so替换它。

事实证明,为了工作 opencv_contrib face 模块,我必须把这个新的 cv2.so 文件放在我的 main.py 存在的同一个文件中。我不知道这是否首先应该是这样。我完全是自己偶然发现的。

在此之后,我的代码工作没有任何错误。

于 2017-10-25T20:20:30.597 回答