User`s guide
Starting and Stopping Image Acquisition
5-15
Starting and Stopping Image Acquisition
Once openDevice() returns successfully, the engine calls your adaptor's
startCapture() function to start acquiring data.
The engine calls your adaptor's stopCapture() function when a user calls the stop or
closepreview function on a video input object, or when the specified number of frames
has been acquired and the acquisition is complete. For example,
vid = videoinput('winvideo',1);
set(vid,'FramesPerTrigger',1000); //
start(vid);
stop(vid);
Suggested Algorithm for startCapture()
The startCapture() function typically performs the following tasks.
1
Check whether an acquisition is already occurring, using the IAdaptor member
function isAcquiring(). If it is, exit.
2
Send a message to the acquisition thread, using the Windows
PostThreadMessage() function, telling it to begin acquiring image frames from
the device. See “Sending a Message to the Acquisition Thread” on page 5-15 for
more information.
Note Sending a start message to the acquisition thread is only required if your
adaptor uses a thread-based design. Adaptors can also use asynchronous interrupts
(callbacks) to acquire frames, if the device supports this. Refer to the documentation
that came with your device's SDK for more information.
The startCapture() function also typically makes sure that the latest image
acquisition object properties are used (see “Implementing Get and Set Support for
Device-Specific Properties” on page 6-10), and configures hardware triggers, if
supported and set (see “Supporting Hardware Triggers” on page 5-27).
Sending a Message to the Acquisition Thread
To send a message to a thread, use the Windows PostThreadMessage() function.
The adaptor's acquisition thread function uses the Windows GetMessage() function to
receive these messages — see “Example: Opening a Connection” on page 5-11.