InternalPwm

Note

This command is only supported on X- and XR-serias cameras.

When working with a X- or XR-series camera the strong led flashes may be distracting for a lot of people. The internal PWM allows the led to be activated at high frequency, so a seemingly constant illumination is produced, which may be less distracting than single flashes.

The internal PWM can trigger both led and cameras, so the cameras will receive a trigger singal during an led flash.

Usage example for constant illumination:

auto const serial = "1234"; // Replace with your camera's serial number

// Call the Open command to open the camera
NxLibCommand open(cmdOpen);
open.parameters()[itmCameras] = serial;
open.execute();

NxLibCommand internalPwm(cmdInternalPwm);
internalPwm.parameters()[itmCameras] = serial;
internalPwm.parameters()[itmFrequency] = 75;   // Set frequency to 75Hz
internalPwm.parameters()[itmDutyCycle] = 0.09; // Set duty cycle to 9%
internalPwm.parameters()[itmOutput][itmLeft] =
    true; // Trigger the left camera (which in turn will trigger the right camera)
internalPwm.parameters()[itmOutput][itmLED] = true; // Trigger the projector LED
internalPwm.execute();

NxLibItem camera = NxLibItem()[itmCameras][itmBySerialNo][serial];

// The internal PWM signal is high active. Set the camera to trigger on a rising edge on the GPIO port.
camera[itmParameters][itmCapture][itmTriggerMode] = valRisingEdge;

// The camera will now be constantly triggered through the internal PWM, so we only have to retrieve the images on
// demand using the Retrieve command.

for (int imageIndex = 0; imageIndex < 10; imageIndex++) {
	NxLibCommand retrieve(cmdRetrieve);
	while (true) {
		retrieve.parameters()[itmTimeout] = 0;
		retrieve.execute();
		if (retrieve.result()[serial][itmRetrieved].asBool()) {
			// A new image has been received and copied into the raw image node
			break;
		}
	}

	// Compute the disparity map, point map, and process the data according to your needs
}