frames 2 video

Download Frames 2 Video

If you can't read please download the document

Upload: jahanzeb

Post on 16-Dec-2015

2 views

Category:

Documents


1 download

DESCRIPTION

matlab convertion of frames to video

TRANSCRIPT

ImFolder=uigetdir;pngFile = dir(strcat(ImFolder,'\*.png'));S = [pngFile(:).datenum]; [S,S] = sort(S);pngFiles = pngFile(S);VideoFile=strcat(ImFolder,'\Video');writeObj = VideoWriter(VideoFile);fps= 15; writeObj.FrameRate = fps;open(writeObj);for t= 1:length(pngFiles) Frame=imread(strcat(ImFolder,'\',pngFiles(t).name)); writeVideo(writeObj,im2frame(Frame));endclose(writerObj);Explanation of the above code: # ImFolder=uigetdir; --> This line when executed, will open a browse window in which you can select your desired folder, where the frames or sequence of images is. The path will be stored in the variable ImFolder.# pngFile = dir(strcat(ImFolder,'\*.png')); --> here the variable pngFile will be a structure that contain all the names of PNG files that are in the directory you have specified. If your image files are in jpeg format, so give the above command as dir(strcat(ImFolder,'\*.jpg')). Here '\*.png' will be acting as a wildcard for all the PNG files available in that folder.# S = [pngFile(:).datenum]; [S,S] = sort(S);--> This 2 lines of code will sort the files according to the datenum property of the pngFile structure.# pngFiles = pngFile(S); --> creating another variable pngFiles same as pngFile , but the former contains the files list in sorted form.# VideoFile=strcat(ImFolder,'\Video'); --> Creating a Video File name as Video# writeObj = VideoWriter(VideoFile); --> This will create a Video Object named writeObj.# fps= 15; --> specifying the frame rate as 15 (or whatever is required or whatever you want). Your video file length will be decided by the value of fps and the number of the image files.# writeObj.FrameRate = fps; --> we have set the FrameRate property of writeObj video object as specified in the variable fps.# open(writeObj); --> Open to start writing the frames in the writeObj video object.# for t= 1:length(pngFiles) Frame=imread(strcat(ImFolder,'\',pngFiles(t).name)); writeVideo(writeObj,im2frame(Frame));end--> These 4 lines will write the frames in the newly created video file, that is initially empty.# close(writeObj); --> close the writeObj to complete the video write process.After this line of code's execution a video file will be created the the root folder with the name Video.avi or what ever you have specified.Screenshots:Initial Frame Sequence, that we have, before applying this code on this folder, Create A Video File From A Sequence Of Image, Using MATLABInitial Frame Sequence, that we have, before applying this code on this folderThe working directory indicating the frames along with the output video file, Create A Video File From A Sequence Of Image Stored in a Folder, Using MATLAB The working directory indicating the frames along with the output video fileCreate A Video File From A Sequence Of Image Stored in a Folder, Using MATLAB,The output video file along with the frames, The output video file along with the frames,The main idea behind the code was obtained from the blog below (We adapted it for Our need though!), it does has various topics about image processing, do refer it:http://imageprocessingblog.com/how-to-create-a-video-from-image-files/AUTHOR: VIBHUTESH KUMAR SINGHAn active & prominent author at Digital iVision Labs! Specializing in MATLAB, C++, Arduino, OpenCV, NI Labview, Web Designing & other Electronics stuffs! Just started M.Tech. From IIIT Delhi, looking for excellent PhD Opportunities with prominent researchers. Drop a mail: vibhutesh[at]gmail.com or Follow him at....FacebookTwitterGoogle+LinkedinStart Linkedin Registered Social networking site Picture Frame Digital photo frameFacebooks Promotional Codes Overstock promo codes 2 Line Start Linkedin1 comment:MerPati PutehDecember 10, 2013 at 6:30 AMits ok...i already frust... stillRead more: http://www.divilabs.com/2013/12/create-video-file-from-sequence-of.html#ixzz3Q23pWnsD