Opening a Camera and Setting Parameters

This example shows how to open a camera and modify some camera parameters thereafter.

Code Examples

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

// replace "1234" with your camera's serial number:
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/1234"

// Call the Open command to open the camera
NxLibCommand open(cmdOpen); // Note: the variable name 'open' does not matter; the constant 'cmdOpen'
// specifies the name of the command to be executed when '.execute()' is called
// on the object.
// Set parameters for the command
open.parameters()[itmCameras] =
    "1234"; // Insert the serial number of the camera to be opened into the Cameras parameter of Open
open.execute();

// At this point the parameter tree under /Cameras/1234/Parameters contains the default values for all
// settings.

// Disable auto-exposure, auto-gain and set exposure to 5ms and
// gain factor to 1.0 (i.e. no analog gain)
camera[itmParameters][itmCapture][itmAutoExposure] = false;
camera[itmParameters][itmCapture][itmAutoGain] = false;
camera[itmParameters][itmCapture][itmExposure] = 5.0;
camera[itmParameters][itmCapture][itmGain] = 1.0;

// You can now grab images and generate 3D point clouds with the new settings
// ...
* Open the camera and reference the camera's item at path "/Cameras/BySerialNo/1234"
* replace "1234" with your camera's serial number
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Stereo', '1234', 0, 0, CameraHandle)

* At this point the parameter tree under /Cameras/1234/Parameters contains the default values for all settings.

* Disable auto -exposure, auto -gain, and set exposure to 5ms and gain factor to 1.0 (i.e. no analog gain)
set_framegrabber_param (CameraHandle, 'Parameters/Capture/AutoExposure', 'false')
set_framegrabber_param (CameraHandle, 'Parameters/Capture/AutoGain', 'false')
set_framegrabber_param (CameraHandle, 'Parameters/Capture/Exposure', 5.0)
set_framegrabber_param (CameraHandle, 'Parameters/Capture/Gain', 1.0)

* You can now grab images and generate 3D point clouds with the new settings
* ...

Aternative, more compact version by creating another reference to the capture parameter subtree first:

// Create an NxLibItem referencing the capture parameter subtree
NxLibItem captureParameters = camera[itmParameters][itmCapture];

captureParameters[itmAutoExposure] = false;
captureParameters[itmAutoGain] = false;
captureParameters[itmExposure] = 5.0;
captureParameters[itmGain] = 1.0;
* Create an NxLibItem referencing the capture parameter subtree
get_framegrabber_param (CameraHandle, 'path', CameraPath)
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', CameraPath + '/Parameters/Capture', 0, 0, CaptureParametersHandle)

set_framegrabber_param (CaptureParametersHandle, 'AutoExposure', 'false')
set_framegrabber_param (CaptureParametersHandle, 'AutoGain', 'false')
set_framegrabber_param (CaptureParametersHandle, 'Exposure', 5.0)
set_framegrabber_param (CaptureParametersHandle, 'Gain', 1.0)