简体   繁体   English

我无法使用最新的 opencv 版本创建识别器

[英]I can't create an recognizer using the lastest opencv version

I'm' trying to build a face recognition project with python.我正在尝试使用 python 构建人脸识别项目。 But I've found a problem, I can't instantiate the recognizer because when I try execute this line:但是我发现了一个问题,我无法实例化识别器,因为当我尝试执行此行时:

recognizer = cv2.face.LBHFaceRecognizer_create()

I got this error:我收到了这个错误:

AttributeError: module 'cv2.cv2' has no attribute 'face' AttributeError:模块'cv2.cv2'没有属性'face'

So I've searched for a solution in the web, much of them, suggested to execute this command on terminal:所以我在 web 中搜索了解决方案,其中很多人建议在终端上执行此命令:

pip install opencv-contrib-python pip 安装 opencv-contrib-python

it doesn't solve the problem, I've tried to reinstall to but the problem remains.没有解决问题,我试过重新安装,但问题依旧。 I've seek information about the documentation but it looks that there's a miss of information about how to create an recognizer in the web.Do Someone know how to solve the problem?我已经寻找有关文档的信息,但似乎缺少有关如何在 web 中创建识别器的信息。有人知道如何解决这个问题吗?

It works for me with a slight modification:它对我有用,只需稍作修改:

recognizer = cv2.face.LBPHFaceRecognizer_create()

I added a P after LB.我在LB之后加了一个P。

I have a working example here在这里有一个工作示例

If someone knows how to solve the problem this post shows exactly the solution for this problems step by step, it's only follow the first answer:如果有人知道如何解决这个问题,这篇文章一步一步地显示了这个问题的解决方案,它只遵循第一个答案:

No module named 'cv2.cv2' 没有名为“cv2.cv2”的模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM