我是Matlab新手,尝试在Matlab中编程一个GUI,它将在我的笔记本电脑上显示一个小窗口中的摄像头。我试图创建一个函数,推动它将启动我已经完成的摄像头,但同时我想要拍摄5秒快照并在我的主窗口中显示图像。我需要这方面的帮助。如何将图形大小设置为更大。下面是我的MATLAB代码在Matlab GUI和函数中编程
% Create a video input object.
vid = videoinput('winvideo');
% Create a figure window. This example turns off the default
% toolbar and menubar in the figure.
hFig = figure('Toolbar','none',...
'Menubar', 'none',...
'NumberTitle','Off',...
'Name','LegoBot');
% Set up the push buttons
uicontrol('String', 'Start Preview',...
'Callback', 'preview(vid)',...
'Units','normalized',...
'Position',[0 0 0.15 .07]);
uicontrol('String', 'Stop Preview',...
'Callback', 'stoppreview(vid)',...
'Units','normalized',...
'Position',[.17 0 .15 .07]);
uicontrol('String', 'Close',...
'Callback', 'close(gcf)',...
'Units','normalized',...
'Position',[0.34 0 .15 .07]);
% Create the text label for the timestamp
hTextLabel = uicontrol('style','text','String','Timestamp', ...
'Units','normalized',...
'Position',[0.85 -.04 .15 .08]);
% Create the image object in which you want to
% display the video preview data.
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
hImage = image(zeros(imHeight, imWidth, nBands));
% Specify the size of the axes that contains the image object
% so that it displays the image at the right resolution and
% centers it in the figure window.
figSize = get(hFig,'Position');
figWidth = figSize(7);
figHeight = figSize(8);
set(gca,'unit','pixels',...
'position',[ ((figWidth - imWidth)/2)...
((figHeight - imHeight)/2)...
imWidth imHeight ]);
% Set up the update preview window function.
setappdata(hImage,'UpdatePreviewWindowFcn',@mypreview_fcn);
% Make handle to text label available to update function.
setappdata(hImage,'HandleToTimestampLabel',hTextLabel);
preview(vid, hImage);
我不能强调在MATLAB以外的指南中开发GUI是一项非常困难的任务,并且不适用于初学者。 – linuxuser27 2011-03-30 16:44:21
...那么真正的问题是什么?我可以第二个linuxuser的建议使用指南,这有助于你的情况?如果不是,实际问题是什么? – 2011-04-13 15:06:09