首页 > 解决方案 > 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)

标签: python-3.xopencv3.0tracking

解决方案


看起来frame变量是None. IE。

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

cap在我们提供帮助之前,您需要提供更多信息。


推荐阅读