人脸识别报错解决:AttributeError: module ‘cv2.cv2’ has no attribute ‘face’
人脸识别报错如下:AttributeError: module ‘cv2.cv2’ has no attribute ‘face’
问题描述
代码中cv2没有face模块所以报错,看了很多博主都是卸载和重新安装opencv-python库和opencv-contrib-python都是不行的,下面参考一位博主的亲测有用
![在这里插入图片描述](https://img-blog.csdnimg.cn/0f4ec39fd52640ba9cd9ad08dd9be12e.png)
recognizer = cv2.face.LBPHFaceRecognizer_create()
解决方案:
直接在自己的虚拟环境下安装opencv-contrib-python库,后面一定要加
–user,命令如下
pip install opencv-contrib-python --user
下载成功的样子如下:
![在这里插入图片描述](https://img-blog.csdnimg.cn/871bca5115904b5db20791d02c2da99b.png)
然后运行程序就可以了,结果如下:
![在这里插入图片描述](https://img-blog.csdnimg.cn/b40559b2bace4cf4883cbf8ae603d3fe.png)
参考链接: https://blog.csdn.net/CLionheart/article/details/109900734