[英]GUI in MATLAB for video
我有一個約200幀的視頻。 我想捕獲每10幀,對其進行一些圖像處理,然后將原始圖像與繪圖一起顯示(在我的圖像處理步驟之后)。 輸出應該首先是第10幀及其圖,只有在我單擊按鈕后,它才應繼續前進並在第20幀上進行處理,顯示等等。 一旦我得到所需的幀例如。 第180幀,我想顯示到達該幀所需的總時間(如果幀速率為10幀/秒,則它應該顯示18秒)。
到現在為止,我一直在處理單獨的幀,並對它們進行圖像處理,然后手動計算結果。 但是GUI可以使此過程更有效
整潔的問題。 您可以執行以下操作:
filelist = dir('*.bmp')
)來獲取您正在使用的文件夾中所有圖像文件的列表。 handles.filelist = filelist
。 在使用它時,添加另一個句柄值以保存當前圖像索引, handles.frameindex = 1
,稍后需要。 不要忘記以后再更新guidata ! 在按鈕的按下回調函數中,執行以下操作:
filelist = handles.filelist; frameindex = handles.frameindex; currentframefile = filelist(frameindex); handles.frameindex = frameindex+1;
在現有的GUI中使用currentframefile,它是一個包含當前框架名稱的字符串。
如果我正確理解,這應該可以回答您的問題。 讓我知道您是否需要澄清。 祝好運!
好吧,你的問題很簡單
您必須為處理圖像每隔10幀進行迭代。
您可以使用子圖功能在一個圖形中繪制不同圖形。
subplot(n,m,p) = takes 3 arguments
n = number of rows
m = number of columns
p = location of current figure (from left to right , top to bottom flow)
因此subplot(1,2,2)
將圖形分為兩部分(單行和兩個列),並在第二列中繪制圖形。
waitforbuttonpress
將允許您暫停屏幕,直到您在圖形上單擊鼠標或按任意鍵。
幸運的是我做了非常相似的事情
我更改了一些代碼,我認為這就是您想要做的。
該代碼是自解釋的,因為有注釋...
% get a video file
[f, p] = uigetfile({'*.avi'});
% create a video reader object.
frames = VideoReader([p,f]);
get(frames);
% get the framerate of video
fps = frames.FrameRate;
% get the number of frames in video
nframes = frames.NumberOfFrames;
pickind = 'jpg';
% create a figure to plot on
figure,
% iterate for each 10th frame in image (in step of 10)
for i = 10:10:nframes
%Use your fps to calculate time elasped
disp('Time Elasped:');
disp(i/fps);
% read a frame to image
I = read(frames, i);
% in first row & first column 1st plot will be the original image
% itself
subplot(1,2,1);
imshow(I) ;
% in first row & second column 2nd plot will be a graph of
% processed image (do your image processing here)
subplot(1,2,2);
imhist(rgb2gray(I));
% Hit a key to process next 10th frame from video
k = waitforbuttonpress ;
end
%close the figure
close
由於Matlab文檔本身包含大量材料,因此需要對figures, plots and subplots
進行正確注釋,以了解figures, plots and subplots
。
快樂學習
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.