PVCAM
3.9.x
Programmable Virtual Camera Access Method library
|
This sample is similar to Single Image Callbacks except that most PVCAM functions are called from a background thread - this allows us to control multiple cameras simultaneously.
Initialize PVCAM and open multiple cameras using the InitAndOpenMultipleCameras
helper function. The cMultiCamCount
is a constant defined in a common code part that is set to 2. If there are fewer than cMultiCamCount
cameras available, the nrOfCameras
value is updated with actual number of opened cameras.
The only task of the main thread is to execute a separate background thread for each camera. If an error occurs, all existing threads are requested to exit and the application proceeds with cleanup and termination. The threadAbortFlag
is checked inside WaitForEofEvent function that is running for every camera.
The callback handler registration, acquisition setup, buffer memory allocation, acquisition capture loop and resource cleanup is identical to Single Image Callbacks. Here, this call sequence is repeated for every camera. The only difference is usage of global mutex g_printMutex
to serialize access to standard output stream to avoid corruption of output messages.
At the end we have to wait for all background threads to finish, either by completing the sequence acquisition or by user interruption. After that, the program can proceed with cleanup and termination. For more details, please, refer to the Closing Camera and Uninitializing PVCAM section.