User`s guide

8 Using Events and Callbacks
8-16
Too many input arguments.
Warning: The FramesAcquiredFcn 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.
Viewing a Sample Frame
This example creates a video input object and sets the frames acquired event callback
function property to the display_frame function, created in “Writing a Callback
Function” on page 8-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 image acquisition object — This example creates a video input object
for a Matrox image acquisition device. To run this 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.
vid = videoinput('matrox', 1);
2
Configure property values — This example sets the FramesPerTrigger value
to 30 and the TriggerRepeat property to 4. The example also specifies as the value
of the FramesAcquiredFcn callback the event callback function display_frame,
created in “Writing a Callback Function” on page 8-13. The object will execute
the FramesAcquiredFcn every five frames, as specified by the value of the
FramesAcquiredFcnCount property.
vid.FramesPerTrigger = 30;
vid.TriggerRepeat = 4;
vid.FramesAcquiredFcnCount = 5;
vid.FramesAcquiredFcn = {'display_frame'};
3
Acquire data — Start the video input object. Every time five frames are acquired,
the object executes the display_frame callback function. This callback function
displays the most recently acquired frame logged to the memory buffer.
start(vid)
4
Clean up — Always remove image acquisition objects from memory, and the
variables that reference them, when you no longer need them.