【问题标题】:GUI in MATLAB for videoMATLAB 中用于视频的 GUI
【发布时间】:2014-06-12 19:52:53
【问题描述】:

我有一个大约 200 帧的视频。我想每 10 帧捕获一次,对其进行一些图像处理并将原始图像与绘图一起显示(在我的图像处理步骤之后)。输出应该首先是第 10 帧及其绘图,只有在我单击按钮后,它才能继续并在第 20 帧进行处理,显示它等等。一旦我得到所需的框架,例如。第 180 帧,我想显示到达该帧所用的总时间(如果帧速率为 10 帧/秒,那么它应该显示 18 秒)。

到目前为止,我一直在处理单独的帧并对它们进行图像处理并手动计算结果。但是 GUI 会让这个过程更高效

【问题讨论】:

  • 你有没有试过...
  • 我只做了图像处理部分。我是制作 GUI 和视频处理的新手..因此需要帮助!我制作了一个基本的 gui,一次只能在一个帧上工作,我每次都必须加载新图像。我已经手动将所有视频帧存储在一个文件夹中。这个过程很慢,这就是为什么需要更快的方法

标签: image matlab image-processing video-processing matlab-guide


【解决方案1】:

你的问题很简单
处理图像所需的每 10 帧都必须进行迭代。

您可以使用 subplot 功能在一个图形中绘制不同的图形。

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 将允许您暂停屏幕,直到您在图形上单击鼠标或按任意键。

幸运的是我做了一些非常相似的事情
我改变了一些代码,我认为这就是你想要做的。

由于 cmets,代码是不言自明的......

% 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

要正确注释您的图,请了解 figures, plots and subplots,因为 matlab 文档本身有很多材料。

快乐学习

【讨论】:

  • 谢谢!我知道这部分,它制作一个很困难的 GUI。但现在我确实更清楚了..谢谢!
【解决方案2】:

整洁的问题。以下是您可以执行的操作:

  1. 在程序启动时,使用dir(如:filelist = dir('*.bmp'))获取您正在工作的文件夹中所有图像文件的列表。
  2. 将该列表分配给 guidata 句柄,如下所示:handles.filelist = filelist。当您使用它时,添加另一个句柄值来保存您当前的图像索引handles.frameindex = 1,您稍后将需要它。之后别忘了更新guidata
  3. 在按钮的按下回调函数中,执行以下操作:

    filelist = handles.filelist; frameindex = handles.frameindex; currentframefile = filelist(frameindex); handles.frameindex = frameindex+1;

  4. 在现有的 GUI 中使用 currentframefile,它是一个包含当前帧名称的字符串。

如果我理解正确,这应该可以回答您的问题。如果您需要澄清,请告诉我。祝你好运!

【讨论】:

  • 非常感谢!正是我需要的!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多