-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iterator interface to VideoReader objects (#261)
* Add iterator interface to VideoReader objects I have added an iterator interface to the `VideoReader` type, making collecting all frames of a video as simple as `f = openvideo(fname); imgs = collect(f)`. The iterator returns a new array for each frame, as I think mutating the same array on subsequent calls to `iterate` would be surprising and lead to strange behavior when calling functions such as `collect`. Note that the VideoReader iterator is mutable, like Channel or Stateful iterators in Julia, and will resume iteration where it was last stopped, instead of at the beginning. I have added some text in the documentation explaining this behavior, and also added some tests. * Do not collect all frames into memory to test iterator interface Instead of collecting all frames into memory with `collect` to test the `VideoReader` interface, I am instead testing the iterator interface with a simple for loop. This should reduce the memory requirement for CI, and avoid memory-related test errors on low memory CI VMs. * Simplify test of mutability of `VideoReader` iterator Instead of looping over the iterator to test that there are zero elements remaining, it is simpler to just see if `iterate` returns `nothing`. * Test that iterator interface for `VideoReader` does not mutate frames I have added a test to verify that frames returned by the `VideoReader` iterator interface have distinct storage.
- Loading branch information
1 parent
0f211c2
commit 004431b
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters