模块“cv2.cv2”没有属性“face”

2024-09-28 17:27:36 发布

您现在位置:Python中文网/ 问答频道 /正文

在以下代码中,我在以下步骤中遇到错误:

model = cv2.face.LBPHFaceRecognizer_create()

[]

错误:

^{pr2}$

Tags: 代码model错误create步骤cv2facepr2
1条回答
网友
1楼 · 发布于 2024-09-28 17:27:36

face模块实际上并不是opencv库的一部分。相反,opencv-contrib库的^{} is part。从the readme

This repository [opencv-contrib] is intended for development of so-called "extra" modules, contributed functionality. New modules quite often do not have stable API, and they are not well-tested. Thus, they shouldn't be released as a part of official OpenCV distribution, since the library maintains binary compatibility, and tries to provide decent performance and stability.

opencv-contrib需要单独安装。正如@james指出的(在一个已经被删除的评论中),当前获取Python版本的简单方法是:

pip install opencv-contrib-python

运行上述pip调用后,代码应该可以工作了。在

相关问题 更多 >