User`s guide

Creating and Executing Callback Functions
M-file callback functions require at least two input arguments:
The image acquisition object
The event structure associated with the event
The function header for this callback function illustrates this basic syntax.
function mycallbac k(ob j,event)
The first argument, obj, is the image acquisition object itself. Because the
object is available, you can use in your callback function any of the toolbox
functions, such as
getdata, that require the object as an argument. You can
also access all o bject properties.
The second argument,
event, is the event structure associated with the event.
This event information pertains only to the event that caused the callback
function to execute. For a complete list of supported event types and their
associated ev ent structures, see “Event Structures” on page 7-7.
In addition to these two required input arguments, you can also specify
additional, application-specific arguments for your callback function.
Note To receive the object and event arguments, and any additional
arguments, you must use a cell array when specifying the name of the function
as the value of a callback property. For more inform ation, see “Specifying
Callback Functions” on page 7-14.
Example: Writing a Callback Function
To illustrate, this example implements a callb ack function for a
frames-acquired event. This callback function enables you to monitor the
frames being acquired by viewing a sa m ple fram e pe rio dically.
To implement this function, the callback function acquires a single frame
of data and displays the acquired frame in a MATLAB figure window. The
function also accesses the event structure passed as an argument to display
the timestamp of the frame being displayed. The
drawnow command in the
callback function forces M ATLAB to update the display.
7-13