Image Acquisition Toolbox Previous page   Next Page

Specifying Callback Functions

You associate a callback function with a specific event by setting the value of the event's callback property. The video input object supports callback properties for all types of events.

You can specify the callback function as the value of the property in any of three ways:

The following sections provide more information about each of these options.

Using a Text String to Specify Callback Functions

You can specify the callback function as a string. For example, this code specifies the callback function mycallback as the value of the start event callback property StartFcn for the video input object vid.

In this case, the callback is evaluated in the MATLAB workspace.

Using a Cell Array to Specify Callback Functions

You can specify the callback function as a text string inside a cell array.

For example, this code specifies the callback function mycallback as the value of the start event callback property StartFcn for the video input object vid.

To specify additional parameters, include them as additional elements in the cell array.

The first two arguments passed to the callback function are still the video input object (obj) and the event structure (event). Additional arguments follow these two arguments.

Using Function Handles to Specify Callback Functions

You can specify the callback function as a function handle.

For example, this code specifies the callback function mycallback as the value of the start event callback property StartFcn for the video input object vid.

To specify additional parameters, include the function handle and the parameters as elements in the cell array.

If you are 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, or trigger toolbox functions as callbacks. For example, this code sets the value of the stop event callback to the Image Acquisition Toolbox start function.

Disabling Callbacks

If an error occurs in the execution of the callback function, the toolbox disables the callback and displays a message similar to the following.

To enable a callback that has been disabled, set the value of the property associated with the callback or restart the object.


Previous page  Creating Callback Functions Example: Viewing a Sample Frame Next page

Learn more about the latest releases of MathWorks products:

 © 1994-2010 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS