Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you will have to check the ret value inside your loop, like this:

while(cap.isOpened()):
  ret, frame = cap.read()
  if not ret: # the movie's over, we can go home.
     break

you will have to check the ret value inside your loop, like this:

while(cap.isOpened()):
  ret, frame = cap.read()
  if not ret: # the movie's over, we can go home.
     break

(if the video finished, there are no more frames to retrive, and VideoCapture returns empty (None) frames. if you throw those at cvtColor or such, you will get this error msg)

you will have to check the ret value inside your loop, like this:

while(cap.isOpened()):
  ret, frame = cap.read()
  if not ret: # the movie's over, we can go home.
     break

(if the video finished, there are no more frames to retrive, retrieve, and VideoCapture returns empty (None) frames. if you throw those at cvtColor or such, you will get this error msg)