[英]module 'cv2.cv2' has no attribute 'face'
In the following code, i am getting error at following step:在以下代码中,我在以下步骤中遇到错误:
model = cv2.face.LBPHFaceRecognizer_create()
[ [
Error:错误:
AttributeError: module 'cv2.cv2' has no attribute 'face'
The face
module isn't actually a part of the opencv
library proper. face
模块实际上并不是opencv
库的一部分。 Rather, face
is part of the opencv-contrib
library.相反,
face
是opencv-contrib
库的一部分。 From the readme :从 自述文件:
This repository [
opencv-contrib
] is intended for development of so-called "extra" modules, contributed functionality.这个存储库 [
opencv-contrib
] 用于开发所谓的“额外”模块,贡献功能。 New modules quite often do not have stable API, and they are not well-tested.新模块通常没有稳定的 API,并且它们没有经过很好的测试。 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 发行版的一部分发布,因为该库保持二进制兼容性,并试图提供不错的性能和稳定性。
opencv-contrib
needs to be installed separately. opencv-contrib
需要单独安装。 As @james pointed out (in a now deleted comment), the current easy way to get the Python version is to just do:正如@james 指出的(在现已删除的评论中),当前获取 Python 版本的简单方法是:
pip install opencv-contrib-python
After you run the above pip
call, your code should work.运行上述
pip
调用后,您的代码应该可以工作了。
Do this:做这个:
pip uninstall opencv_contrib_python
and install again:并再次安装:
pip install opencv_contrib_python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.