Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FileVideoStream NoneType error when reaching end of file #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BCLegon
Copy link

@BCLegon BCLegon commented Apr 14, 2019

Problem

When using the FileVideoStream class to read a video file, reaching the end of the file raises an error similar to the following:

  File ".../python3.6/site-packages/imutils/convenience.py", line 69, in resize
    (h, w) = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'

This is because the last frame returned by FileVideoStream.read() is not actually a frame, but None.

Solution

When the end of the video file has been reached, the frame variable contains None (line 47). In this case, the frame should not be added to the queue.

The transform function shouldn't be executed either, as we're not sure whether this user-specified function can handle None as input for the frame.

Don't put frame in queue when no frame is grabbed
@ghost
Copy link

ghost commented May 20, 2019

This pull request is identical to #119

@BCLegon
Copy link
Author

BCLegon commented May 20, 2019

Yes, I see now that the code is exactly the same actually. Hopefully, my explanation can still help in clarifying the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant