Main Content

wait

Wait until image acquisition object stops running or logging

Syntax

wait(obj)
wait(obj,waittime)
wait(obj,waittime,state)

Description

wait(obj) blocks the MATLAB® command line until the video input object obj stops running (Running = 'off'). obj can be either a single video input object or an array of video input objects. When obj is an array of objects, the wait function waits until all objects in the array stop running. If obj is not running or is an invalid object, wait returns immediately. The wait function can be useful when you want to guarantee that data is acquired before another task is performed.

wait(obj,waittime) blocks the MATLAB command line until the video input object or array of objects obj stops running or until waittime seconds have expired, whichever comes first. By default, waittime is set to the value of the object's Timeout property.

wait(obj,waittime,state) blocks the MATLAB command line until the video input object or array of objects obj stops running or logging, or until waittime seconds have expired, whichever comes first. state can be either of the following character vectors. The default value is enclosed in braces ({}).

State

Description

{'running'}

Blocks until the value of the object's Running property is 'off'.

'logging'

Blocks until the value of the object's Logging property is 'off'.

Note

The video input object's stop event callback function (StopFcn) might not be called before this function returns.

An image acquisition object stops running or logging when one of the following conditions is met:

  • The stop function is issued.

  • The requested number of frames is acquired. This occurs when

    FramesAcquired = FramesPerTrigger * (TriggerRepeat + 1)

    where FramesAcquired, FramesPerTrigger, and TriggerRepeat are properties of the video input object.

  • A run-time error occurs.

  • The object's Timeout value is reached.

Note

To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.

Examples

Create a video input object.

vid = videoinput('winvideo');

Specify an acquisition that should take several seconds. The example sets the FramesPerTrigger property to 300.

vid.FramesPerTrigger = 300;

Start the object. Because it is configured with an immediate trigger (the default), acquisition begins when the object is started. The example calls the wait function after calling the start function. Notice how wait blocks the MATLAB command line until the acquisition is complete.

start(vid), wait(vid);

Version History

Introduced before R2006a

See Also

| | |