Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Extract Frames from Video MATLAB


There may be situations when we need certain frames from video. You can extract the video frames easily in MATLAB and save to any image format that MATLAB imwrite function supports or you can process the frames directly.

There is a function class called ‘VideoReader’

OBJ = VIDEOREADER(FILENAME) 

        - constructs a multimedia reader object, OBJ, that can read in video data from a multimedia file. 
        - FILENAME is a string specifying the name of a multimedia file.  There are no restrictions on file extensions.
MMREADER can also be used but  MMREADER will be removed in a future release. So better use ‘VideoReader’.
Here is the code to do it.

%vid = video which needs to be extracted
vid = 'worm_gear_set.avi';
readerobj = VideoReader(vid);
vidFrames = read(readerobj);
%get number of frames
numFrames = get(readerobj, 'numberOfFrames');
for k = 1 : numFrames
    mov(k).cdata = vidFrames(:,:,:,k);
    mov(k).colormap = [];
    %imshow(mov(k).cdata);
    imagename=strcat(int2str(k), '.jpg');
    %save inside output folder
    imwrite(mov(k).cdata, strcat('output\frame-',imagename));
end

The frames extracted are saved inside the output folder which will be inside the project directory.

You can download the project files from here.

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.