【问题标题】:rows, cols, _ = frame.shape AttributeError: ‘NoneType’ object has no attribute ‘shaperows, cols, _ = frame.shape AttributeError: ‘NoneType’对象没有属性‘shape
【发布时间】:2019-04-23 17:08:00
【问题描述】:

大家好,当我想执行以下代码时出现错误,任何人都可以帮助我

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)

【问题讨论】:

    标签: python-3.x opencv3.0 tracking


    【解决方案1】:

    看起来frame 变量是None。即。

    _, frame = cap.read() # <- This fails for some reason.
    

    您需要在cap 上提供更多信息,然后我们才能提供帮助。

    【讨论】:

    • 感谢您的快速回答,这是我忘记并给上限的问题,但我使用笔记本电脑的相机,所以我将其更改为 0,现在它工作完美:))))))))) )))))))))))))))))))))))))))))))))))))))))
    猜你喜欢
    • 1970-01-01
    • 2020-11-07
    • 1970-01-01
    • 1970-01-01
    • 2017-09-04
    • 2019-01-01
    • 2021-12-26
    • 2019-07-23
    • 2018-05-13
    相关资源
    最近更新 更多