<< Click to Display Table of Contents >> Navigation: NxLib API > HowTo's > Multithreading > Parallel Usage of Multiple Cameras |
This topic explains how to use two cameras independently by running commands in separate execution nodes.
Please read the topics Opening a Camera and Grabbing 3D Data first.
Note: The code of the two threads only differs in the first two lines which specify a different execution node "thread1" or "thread2" and different camera serial number "1234" or "2345" to operate on.
Thread 1 (opens and uses camera "1234"): std::string executionSlot = "thread1"; // Use a separate execution slot name for all commands carried out by this thread Thread 2 (opens and uses camera "2345"): std::string executionSlot = "thread2"; // Use a separate execution slot name for all commands carried out by this thread |
Open frame grabbers with the parallel_execution flag. All NxLib commands (as well as grab_data operations) will then automatically be executed in a different command slot than the commands for other handles.
Procedure 1 (opens and uses camera "1234") open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', 'parallel_execution=1', 'false', 'Stereo', '1234', 0, 0, CameraHandle) Procedure 2 (opens and uses camera "2345") open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', 'parallel_execution=1', 'false', 'Stereo', '2345', 0, 0, CameraHandle) |