cap = cv2.VideoCapture(video_path)
ret , prev_frame = cap.read()
count = 0
while ret:
ret , curr_frame = cap.read()
a1 = curr_frame[:int(h/2-1),:int(w/2-1)]
错误:
a1 = curr_frame[:int(h/2-1), :int(w/2-1)]
TypeError: 'NoneType' object is not subscriptable
答案 0 :(得分:0)
您可能要测试您的cap.read()语句。很明显,它返回了none
结果。
cap = cv2.VideoCapture(video_path)
ret , prev_frame = cap.read()
count = 0
while ret:
ret , curr_frame = cap.read() or []
a1 = curr_frame[:int(h/2-1),:int(w/2-1)]