User`s guide

Previewing Data
2-17
ht = getappdata(himage,'HandleToTimestampLabel');
% Set the value of the text label.
ht.String = tstampstr;
% Display image data.
himage.CData = event.Data
Specifying the Update Preview Function
To use an update preview window function, store a function handle to your function in
the 'UpdatePreviewWindowFcn' application-defined data of the image object. The
following example uses the setappdata function to configure this application-defined
data to a function handle to the update preview window function described in “Creating
the Update Preview Window Function” on page 2-16.
This example extends the simple custom preview window created in “Previewing Data
in Custom GUIs” on page 2-13. This example adds three push button uicontrol
objects to the GUI: Start Preview, Stop Preview, and Close Preview.
In addition, to illustrate using an update preview window function, the example GUI
includes a text label uicontrol object to display the timestamp value. The update
preview window function updates this text label each time a framed is received. The
example uses setappdata to store a handle to the text label uicontrol object in
application-defined data in the image object. The update preview window function
retrieves this handle to update the timestamp display.
% 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','My Custom Preview GUI');
% Set up the push buttons
uicontrol('String', 'Start Preview',...
'Callback', 'preview(vid)',...
'Units','normalized',...
'Position',[0 0 0.15 .07]);
uicontrol('String', 'Stop Preview',...