看板 MATLAB 關於我們 聯絡資訊
我要用一段影片拿來做影像辨識 用了MATLAB function VideoReader來讀取影片並播放 但在read frame的時候速度很慢 甚至會把電腦記憶體吃掉 造成當機 讀完frame至少要15分鐘以上 影片播出來也頓頓的 我有試過用MATLAB的範例影片跑都很順 但它影片很小 所以想請教問題是在哪? 程式碼我是參考MATLAB的範例: clc,clear; vid = VideoReader('adjust.avi'); nFrames = vid.NumberOfFrames; vidHeight = vid.Height; vidWidth = vid.Width; % 預先分配空間 mov(1:nFrames) = ... struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),... 'colormap', []); % 讀Frames for k = 1 : nFrames mov(k).cdata = read(vid, k); end % 建立GUI視窗 hf = figure; set(hf, 'position', [150 150 vidWidth vidHeight]) % 播放影片 movie(hf, mov, vid.FrameRate); 附上所播放的影像資訊 Duration: 215.5155 Name: 'yongder_adjust.avi' Path: 'C:\Users\Dave\Documents\MATLAB' Tag: '' Type: 'VideoReader' UserData: [] BitsPerPixel: 24 FrameRate: 29.9700 Height: 480 NumberOfFrames: 6458 VideoFormat: 'RGB24' Width: 640 影片原先是mov檔 但檔案1.25G太大 所以我轉成AVI 55.2MB -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.171.198.9 ※ 文章網址: http://www.ptt.cc/bbs/MATLAB/M.1410157409.A.5F7.html