天天看點

matlab中将視訊流轉換成圖檔

function VideoStreamtTOPic(videoname,OutPicPath)

%UNTITLED Summary of this function goes here

%   Detailed explanation goes here

%  input: the name of video stream and the path to save the picture

%  output: picture  

a=mmreader(videoname);

nframes=a.NumberOfFrames;

for i = 1:nframes

im = read(a, i);

imwrite(im,[OutPicPath '.jpg']);

end

end

對于上面程式舉例如下:

在指令視窗或m檔案的編輯視窗輸入以下語句即可;

videoname='mei.mpg';

OutPicPath='K:\視訊流轉成圖檔\mei\';

VideoStreamtTOPic(videoname,OutPicPath)

注意:視訊'mei.mpg'位于matlab目前工作目錄下;

繼續閱讀