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

Adding support for reseting VideoReaders #384

Merged
merged 9 commits into from
Jan 3, 2020
Merged

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Jan 2, 2020

All VideoReaders now implement a reset() method, which allows them to be reset at any time such that the next frame read will the first frame.

This addresses the second half of #373, which has been updated to reflect that the only remaining need is an efficient implementation of seeking to a specific frame.

Test code:

import eta.core.video as etav

video_path = "/path/to/video.mp4"
frames_dir = "/path/to/video/frames"

max_frames = [10, 20, 15]

video_reader = etav.FFmpegVideoReader(video_path)
#video_reader = etav.OpenCVVideoReader(video_path)
#video_reader = etav.SampledFramesVideoReader(frames_dir)

with video_reader as vr:
    for max_frame in max_frames:
        vr.reset()
        frames = []
        for img in vr:
            frames.append(vr.frame_number)
            if vr.frame_number >= max_frame:
                print(frames)
                break

@brimoor brimoor merged commit 0cd1f26 into develop Jan 3, 2020
@brimoor brimoor deleted the reset-video-reader branch January 3, 2020 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Work on a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants