User`s guide

2 Introduction
2-14
The following example creates a figure window and then creates an image object in the
figure, the same size as the video frames. The example then calls the preview function,
specifying a handle to the image object.
% Create a video input object.
vid = videoinput('winvideo');
% Create a figure window. This example turns off the default
% toolbar, menubar, and figure numbering.
figure('Toolbar','none',...
'Menubar', 'none',...
'NumberTitle','Off',...
'Name','My Preview Window');
% Create the image object in which you want to display
% the video preview data. Make the size of the image
% object match the dimensions of the video frames.
vidRes = vid.VideoResolution;
nBands = vid.NumberOfBands;
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
% Display the video data in your GUI.
preview(vid, hImage);
When you run this example, it creates the GUI shown in the following figure.