Running Cameras Hardware Synchronized

This topic shows how to perform hardware synchronization of two cameras. Please read the topics Capturing with Hardware Trigger and Using Digital IOs first for more background on hardware triggered capture operation and IO usage.

Code Examples

We assume to have two cameras connected with the serial numbers “1234” and “2345”. The output of camera “1234” is electrically connected to the input of camera “2345”. We want to run camera “1234” in software trigger mode, and “2345” should run hardware synchronized to the software triggered images of “1234”.

NxLibItem root; // References the tree's root item at path "/"

// Replace "1234" and "2345" with your camera's serial numbers:
NxLibItem camera1 =
    root[itmCameras][itmBySerialNo]["1234"]; // References the camera's item at path "/Cameras/BySerialNo/1234"
NxLibItem camera2 =
    root[itmCameras][itmBySerialNo]["2345"]; // References the camera's item at path "/Cameras/BySerialNo/2345"

// Call the Open command to open the cameras
NxLibCommand open(cmdOpen);
open.parameters()[itmCameras][0] = "1234"; // Use the array parametrization to open both cameras at once
open.parameters()[itmCameras][1] = "2345";
open.execute();

// Configure trigger modes and outputs
camera1[itmParameters][itmCapture][itmTriggerMode] = valSoftware; // This is actually already the default
camera1[itmParameters][itmIO][itmOutput][itmMode] =
    valLowActive; // Camera "1234" should output a 10ms low-active flash signal
camera1[itmParameters][itmIO][itmOutput][itmDuration] = 10.0;
camera2[itmParameters][itmCapture][itmTriggerMode] =
    valFallingEdge; // Camera "2345" will capture on the falling edge of its input signal

for (int imageIndex = 0; imageIndex < 10; imageIndex++) {
	// Execute the Capture command with default parameters
	NxLibCommand capture(cmdCapture);
	capture.execute();
	// Please note that the default parametrization of the Capture command is sufficient for synchronized operation
	// because:
	// * Capture triggers all opened cameras and waits for all cameras to return an image
	// * Cameras configured for hardware triggering are triggered first, so they are always armed and waiting for the
	// trigger signal
	//   before the software triggered camera start its exposure and outputs the trigger signal

	// Now compute the disparity map, point map, and process the data according to your needs
	// ...
}
* References the tree's root item at path "/"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/', 0, 0, RootHandle)

* Replace "1234" and "2345" with your camera's serial numbers
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', 'auto_grab_data=0', 'false', 'Stereo', '1234', 0, 0, CameraHandle1)
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', 'auto_grab_data=0', 'false', 'Stereo', '2345', 0, 0, CameraHandle2)

* Configure trigger modes and outputs
set_framegrabber_param (CameraHandle1, 'Parameters/Capture/TriggerMode', 'Software')
set_framegrabber_param (CameraHandle1, 'Parameters/IO/Output/Mode', 'LowActive')
set_framegrabber_param (CameraHandle1, 'Parameters/IO/Output/Duration', 10.0)
set_framegrabber_param (CameraHandle2, 'Parameters/Capture/TriggerMode', 'FallingEdge')

for Index := 1 to 10 by 1
        * Execute the Capture command with default parameters
        set_framegrabber_param (RootHandle, 'do_execute', 'Capture')
        * Please note that the default parametrization of Capture is sufficient for synchronized operation because:
        * * Capture triggers all opened cameras and waits for all cameras to return an image
        * * Cameras configured for hardware triggering are triggered first, so they are always armed and waiting for the trigger signal
        *   before the software triggered camera start its exposure and outputs the trigger signal

        * Now compute the disparity map, point map, and process the data according to your needs
        * ...
endfor

Note

See Grabbing 3D Data for an example on how to process the data accorsing to your needs