Search code examples
python-3.xopencv3.0tracking

rows, cols, _ = frame.shape AttributeError: ‘NoneType’ object has no attribute ‘shape


Hello everyone i have error when i want to execute the following code a, anyone can help me in this

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)

Solution

  • It looks like the frame variable is None. Ie.

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

    You need to provide some more info on cap before we can help with it.