how to fix opencv NoneType' object has no attribute 'shape'

Viewed 14

How to deal with this? im new with python my file directory is correct, but the error still appears as attachedHow to deal with this?

# Depict some images from source videos (training material)
flag = True
t = []
for j in np.arange(1, 7):
    for i in np.arange(0, 11, 5):
        vidcap = cv2.VideoCapture(r'C:\Users\rafli\Python Subek\Fold1_part1\01\\'+str(j)+'\\'+str(i)+'.mov')
        vidcap.set(cv2.CAP_PROP_POS_MSEC, 20000)      
        success, image = vidcap.read()
        if flag:
            print(image.shape)
        if success:
            image = imutils.resize(image, width=450)
            if flag:
                flag = False
                img = image
                t.append(i)
                break
            if (image[:,0,0].shape[0] >= img[:,0,0].shape[0]):
                img = cv2.hconcat([img, image])
                t.append(i)
    
plt.figure(figsize=(15,10))
plt.axis("off")
[plt.annotate('drowsy', xy=(470 * i + 180, 150), xytext=(450 * i + 20, -5), 
              arrowprops=dict(facecolor='white', shrink=0.05)) for i in np.arange(0, len(t) - 1) if t[i] == 0]
plt.imshow(img[:,:,::-1])


AttributeError: 'NoneType' object has no attribute 'shape'
0 Answers
Related