Skip to content

Instantly share code, notes, and snippets.

@rkh932
Created June 2, 2018 18:02
Show Gist options
  • Save rkh932/b98bc849769707b9c734bfd530652c27 to your computer and use it in GitHub Desktop.
Save rkh932/b98bc849769707b9c734bfd530652c27 to your computer and use it in GitHub Desktop.
%% 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