python-3.x - rows, cols, _ = frame.shape AttributeError: 'NoneType' 对象没有属性 'shape
问题描述
大家好,当我想执行以下代码时出现错误,任何人都可以帮助我
while True:
_, frame = cap.read()
# frame = cv2.resize(frame, None, fx=0.8, fy=0.8)
rows, cols, _ = frame.shape
keyboard[:] = (26, 26, 26)
frames += 1
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
解决方案
看起来frame
变量是None
. IE。
_, frame = cap.read() # <- This fails for some reason.
cap
在我们提供帮助之前,您需要提供更多信息。
推荐阅读
- python - 按钮和标签不会在 Tkinter 中居中(Python 3.8)
- python - 从 Pandas 中的 url 下载 excel 文件(身份验证后)
- javascript - 直接设置图表高度
- django - 如何在pycharm中调试django自定义管理命令
- c++ - 如何查找 3d 点是否在四面体的内部/之上/外部
- python - 为什么我不能得到正确的答案?
- javascript - 对来自 pexel api 的请求数据进行分页
- java - 如何在android studio中检查不可见的复选框
- api - 如何将现有的 REST Api 转换为 GraphQL API
- python - 如何将简单的python计算器的结果存储在变量中