User`s guide

Starting and Stopping Image Acquisition
5-17
Suggested Algorithm for stopCapture()
The stopcapture() function typically performs these tasks.
1
Checks whether the adaptor is already stopped by calling the isAcquiring()
function. If the device is not currently acquiring data, return true.
2
Stops the frame acquisition loop and stops the device, if necessary
Note It is important not to exit the stopCapture() function while the acquisition
thread function is still acquiring frames. One way to do this is to try to acquire a
critical section. When you are able to acquire the critical section, you can be sure
that the frame acquisition loop has ended, giving up its critical section.
Example
The following example illustrates a simple stopCapture() function. This function takes
no arguments and returns a Boolean value indicating whether the video input object is
in stopped state. Replace the stub implementation in the MyDeviceAdaptor.cpp file
with this code and then rebuild your adaptor.
bool MyDeviceAdaptor::stopCapture(){
// If the device is not acquiring data, return.
if (!isOpen())
return true;
//**********************************************************
// Insert calls to your device's SDK to stop the device, if
// necessary.
//**********************************************************
return true;
}
The stopCapture() function in the demo adaptor provides another example of how to
stop the frame acquisition loop. The adaptor defines a flag variable that it checks each
time it enters the frame acquisition loop. To break out of the frame acquisition loop, the
demo adaptor sets this flag variable to false. See the demo adaptor source code for more
details.