问个小问题

橘子皮... 2021-03-15 01:20:33
https://www.toutiao.com/i6924143326145036804/?tt_from=mobile_qq&utm_campaign=client_share×tamp=1612171870&app=news_article&utm_source=mobile_qq&utm_medium=toutiao_android&use_new_style=1&req_id=202102011731090100270240120B002932&share_token=082c62a0-7505-4f3e-8a43-f37a1d3aef88&group_id=6924143326145036804

我试图复现这个文章的结果

import cv2

print(cv2.version.opencv_version)

detector = cv2.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel", "sr.prototxt", "sr.caffemodel")
img = cv2.imread("img.jpg")
res, points = detector.detectAndDecode(img)
print(res, points)

结果提示:

4.5.1.48
Traceback (most recent call last):
File "C:/Users/fio/PycharmProjects/untitled2/fff.py", line 5, in <module>
detector = cv2.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel", "sr.prototxt", "sr.caffemodel")
AttributeError: module 'cv2.cv2' has no attribute 'wechat_qrcode_WeChatQRCode'

可是我的2个opencv库都安装到最新版本了
opencv-contrib-python 4.5.1.48
opencv-python 4.5.1.48
这是什么原因导致无法跑通呢??
...全文
334 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
橘子皮... 2021-03-15
  • 打赏
  • 举报
回复
引用 1 楼 陈年椰子 的回复:
可能是安装cv过程,有部分文件没安装成功。 试试 pip uninstall 再 pip install
我看说明,那个调用方法应该是在opencv-contrib-python里,调用这个模块也是import cv2 嚒?
橘子皮... 2021-03-15
  • 打赏
  • 举报
回复
引用 1 楼 陈年椰子 的回复:
可能是安装cv过程,有部分文件没安装成功。 试试 pip uninstall 再 pip install
你的测试可以嚒?我试了不行
陈年椰子 2021-03-15
  • 打赏
  • 举报
回复
可能是安装cv过程,有部分文件没安装成功。 试试 pip uninstall 再 pip install
保暖婆婆 2022-03-24
  • 举报
回复
@陈年椰子 有效!

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧