Last active
March 30, 2021 01:34
-
-
Save MichaelTr7/33620905943caa399c915fc5d976bc03 to your computer and use it in GitHub Desktop.
A MATLAB function to extract the frames from a video file.
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
function [Frame_Data,Video_Structure] = Grab_Video_Frames(File_Name) | |
Video_Properties = VideoReader(File_Name); | |
Video_Height = Video_Properties.Height; | |
Video_Width = Video_Properties.Width; | |
Number_Of_Frames = Video_Properties.NumFrames; | |
Colour_Channel_Matrix = zeros(Video_Height,Video_Width,3,'uint8'); | |
Video_Structure = struct('cdata',Colour_Channel_Matrix,'colormap',[]); | |
Frame_Index = 1; | |
while(hasFrame(Video_Properties)) | |
Video_Structure(Frame_Index).cdata = readFrame(Video_Properties); | |
Frame_Index = Frame_Index + 1; | |
end | |
Frame_Data = {Video_Structure.cdata}; | |
end |
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
File_Name = "Animated_Blocks_Test.avi"; | |
[Frame_Data,Video_Structure] = Grab_Video_Frames(File_Name); | |
montage(Frame_Data, 'ThumbnailSize', [100 Inf]); | |
implay(Video_Structure); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output Results