| Image Acquisition Toolbox™ | ![]() |
preview(obj)
preview(obj,himage)
himage = preview(...)
preview(obj) creates a Video Preview window that displays live video data for video input object obj. The window also displays the timestamp and video resolution of each frame, and the current status of obj. The Video Preview window displays the video data at 100% magnification (one screen pixel represents one image pixel). The size of the preview image is determined by the value of the video input object ROIPosition property.
Components of a Video Preview Window

The Video Preview window displays image data in its native color space, indicated by the default value of the video input object ReturnedColorSpace property. To determine this value, use propinfo.
The Video Preview window remains active until it is either stopped using stoppreview or closed using closepreview. If you delete the object, by calling delete(obj), the Video Preview window stops previewing and closes automatically.
preview(obj,himage) displays live video data for video input object obj in the image object specified by the handle himage. preview scales the image data to fill the entire area of the image object but does not modify the values of any image object properties. Use this syntax to preview video data in a custom GUI of your own design (see Examples).
himage = preview(...) returns himage, a handle to the image object containing the previewed data. To obtain a handle to the figure window containing the image object, use the ancestor function. For more information about using image objects, see image. See the Custom Update Function section for more information about the image object returned.
Image data is previewed in its native color space, indicated by the default value of the ReturnedColorSpace property of the video input object. To determine the default value for the ReturnedColorSpace property, use propinfo.
The behavior of the Video Preview window depends on the video input object's current state and trigger configuration.
Object State | Preview Window Behavior |
|---|---|
Running=off | Displays a live view of the image being acquired from the device, for all trigger types. The image is updated to reflect changes made to configurations of object properties. (The FrameGrabInterval property is ignored until a trigger occurs.) |
Running=on | If TriggerType is set to immediate or manual, the Video Preview window continues to update the image displayed. If TriggerType is set to hardware, the Video Preview window stops updating the image displayed until a trigger occurs. |
Logging=on | Video Preview window might drop some data frames, but this will not affect the frames logged to memory or disk. |
preview creates application-defined data for the image object, himage, assigning it the name 'UpdatePreviewWindowFcn' and setting its value to an empty array ([]). You can configure the value of the 'UpdatePreviewWindowFcn' application data and retrieve its value using the MATLAB® setappdata and getappdata functions, respectively.
If you set the value of 'UpdatePreviewWindowFcn' to a function handle, preview invokes the function every time a new image frame is available. You can use this function to define custom processing of the previewed image data. When preview invokes the function handle you specify, it passes three arguments to your function:
obj — The video input object being previewed
event — An event structure containing image frame information. For more information, see below.
himage — A handle to the image object that is being updated
The event structure contains the following fields:
Field | Description |
|---|---|
Data | Current image frame specified as an H-by-W-by-B matrix where H and W are the image height and width, respectively, as specified in the ROIPosition property, and B is the number of color bands, as specified in the NumberOfBands property. |
Resolution | String specifying current image width and height, as defined by the ROIPosition property. |
Status | String describing the current acquisition status of the video input object. |
Timestamp | String specifying the timestamp associated with the current image frame. |
Create a customized GUI.
figure('Name', 'My Custom Preview Window');
uicontrol('String', 'Close', 'Callback', 'close(gcf)'); Create an image object for previewing.
vidRes = get(obj, 'VideoResolution'); nBands = get(obj, 'NumberOfBands'); hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); preview(obj, hImage);
For more information on customized GUIs, see Previewing Data in Custom GUIs.
ancestor, closepreview, image, imaqhelp, stoppreview
![]() | peekdata | propinfo | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |