Created
June 2, 2018 18:02
-
-
Save rkh932/b98bc849769707b9c734bfd530652c27 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
%% Load video and labels | |
videoFile = ''; % The video file to use | |
outputPath = ''; % The folder to save to | |
S = load(''); % The .mat file with the labels data | |
labels = S.gTruth.LabelData; | |
%% Extract frames to the outputPath | |
obj = VideoReader(videoFile); | |
fileCount = 0; | |
for i=1:size(labels) | |
if (~isempty(labels(i,1).Water{1})) % Replace Water with whatever label name you are extracting | |
obj.CurrentTime = seconds(labels(i,1).Time); | |
im = obj.readFrame(); | |
fileCount = fileCount + 1; | |
imwrite(im,sprintf('output%d.png',fileCount),'PNG'); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment