User`s guide
7 Using Events and Callbacks
If you a re executing a local callback function from within an M-file, you must
specify the callback as a function handle.
Specifying a Toolbox Function as a Callback
In addition to specifying callback functions of your own creation, you can
also specify the
start, stop,ortrigger toolboxfunctionsascallbacks.
For example, this code sets the value of the stop event callback to Image
Acquisition Toolbox
start function.
vid.StopFcn = @start;
Disabling Callbacks
If an error occurs in the execution of the callback function, the toolbox disables
the callback and d isplays a message sim i lar to the follow ing.
start(vid)
??? Error using ==> frames _cb
Too many input arguments.
Warning: The FramesAcq uiredFcn callback is being disabled.
To enable a callback that has been disabled, set the value of the property
associated with the callback or restart the object.
Example: Viewing a Sample Frame
This example creates a video input object and sets the frames acquired
event callback function p roperty to the
display_frame function, cre ated in
“Example: Writing a Callback F unction” on page 7-13.
The example sets the
TriggerRepeat property of the object to 4 so that 50
frames are acquired. When run, the example displays a sample frame from
the acquired data every time five frames have been acquired.
1 Create an im age acquisition object — Th i s example creates a video
input o bj ect for a M atrox ima ge acquisition device. To run th is example on
your system, use the
imaqhwinfo function to get the object constructor for
your image acquisition device and substitute that syntax for the following
code.
7-16