How to save image of a video.avi file into the folder where Matlab is running as image.bmp file?
14 ビュー (過去 30 日間)
古いコメントを表示
Motivation: I'm currently using VirtualDub v1.9.11 (Free Software) to load a video.avi file and extract all images one by one and save them as .bmp, which later I use in Matlab.
What I want to do: I would like to load a video.avi file and save each image of the video in the current folder where Matlab is running using the following naming and extension: 1.bmp 2.bmp 3.bmp n.bmp and so son.
*What I have done so far:* Until now I know only to load the video using the command lines below:
cd 'C:\Program Files\MATLAB\R2011a\toolbox\vision\visiondemos';
M = mmreader('shaky_car.avi');
N = M.NumberOfFrames;
for ii = 1:N
image(M.read(ii));
pause(0.1);
end
cd C:\Users\Emerson\Desktop\MOVIE_ANALYSIS
For this particular case, the video shaky_car.avi has 132 images, so the folder would be filled with the files 1.bmp, 2.bmp, 3.bmp, and so on until 132.bmp.
I wonder if someone could tell me how to write the command lines to do this job.
Thanks in advance for your help
Emerson
0 件のコメント
採用された回答
Chandra Kurniawan
2012 年 1 月 17 日
Hi,
'shaky_car.avi' is already exist in visiondemos folder,
so you do not need to change the directory by
cd 'C:\Program Files\MATLAB\R2011a\toolbox\vision\visiondemos';
Just try my code and I hope this works on your machine.
obj = mmreader('shaky_car.avi');
vid = read(obj);
nFrame = size(vid,4);
for k = 1 : nFrame
newname = strcat(num2str(k),'.bmp');
imwrite(vid(:,:,:,k), newname);
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Import, Export, and Conversion についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!