Quantcast

Documentation Center

  • Trial Software
  • Product Updates

preview

Preview of live video data

Syntax

preview(obj)
preview(obj,himage)
himage = preview(...)

Description

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 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.

Notes

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.

    Note:   The Image Acquisition Toolbox™ Preview window and the Preview window that is built into the Image Acquisition Tool support the display of up to 16-bit image data. The Preview window was designed to only show 8-bit data, but many cameras return 10-, 12-, 14-, or 16-bit data. The Preview window display supports these higher bit-depth cameras. However, larger bit data is scaled to 8-bit for the purpose of displaying previewed data. If you need the full resolution of the data, use the getsnapshot or getdata functions.

Custom Update Function

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.

The 'UpdatePreviewWindowFcn' will not necessarily be called for every frame that is acquired. If a new frame is acquired and the 'UpdatePreviewWindowFcn' for the previous frame has not yet finished executing, no update will be generated for the new frame. If you need to execute a function for every acquired frame, use the FramesAcquiredFcn instead.

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.

Examples

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.

See Also

| | | |

Was this topic helpful?