Set Z-Range

The z-range of the measurement volume depends on the disparity settings minimum disparity and number of disparities of the stereo matcher and the camera calibration data. There are 2 options to set the desired z-range:

  1. Set z-coordinate of far and near plane of the measurement volume node; NxLib will internally take care of setting the necessary disparity settings according to the current camera calibration.

  2. Set minimum disparity and number of disparities values manually; however these values will in general not result in the same measurement volume when the cameras is exchanged because of different camera calibration data.

Set distance of measurement volume far/near plane

To adjust the measurement volume you can directly set the distance of the near and far plane of the measurement volume.

It does not matter whether the z-coordinate of LeftBottom, LeftTop, RightBottom or RightTop is set.

Note

For the following code samples the camera has to openend already. See Opening a Camera topic for more information.

NxLibItem root;                              // References the tree's root item at path "/"
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/BySerialNo/1234"

NxLibItem measurementVolume = camera[itmParameters][itmDisparityMap][itmMeasurementVolume];

measurementVolume[itmFar][itmLeftBottom][2] = farDistance;
measurementVolume[itmNear][itmLeftBottom][2] = nearDistance;

The NxLib will translate the given distances to disparity settings and apply these directly. The final distances will still be limited by the possible disparity values.

Note

The resulting disparity settings will be rounded so that the given near and far distances will always be included in the measurement range. The resulting range will in general be slightly larger because of the granularity of the disparity parameters.

Set MinimumDisparity and NumberOfDisparity

NxLibItem root;                              // References the tree's root item at path "/"
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/BySerialNo/1234"

NxLibItem stereoMatching = camera[itmParameters][itmDisparityMap][itmStereoMatching];

stereoMatching[itmMinimumDisparity] = minDisp;     // set minimum disparity to desired value
stereoMatching[itmNumberOfDisparities] = numDisps; // set number of disparity to desired value

The command cmdEstimateDisparitySettings can be helpful for a rough estimation on what settings should be used for the current scene.

NxLibItem root;                              // References the tree's root item at path "/"
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/1234"

// The camera must already be open. See Opening a Camera topic for more information.
// Also there must be a pair captured raw images beforehand, in order to estimate disparity settings..
NxLibCommand estimateDisparitySettings(cmdEstimateDisparitySettings);
estimateDisparitySettings.execute();

int minDisp = estimateDisparitySettings.result()["1234"][itmMinimumDisparity].asInt();
int numDisps = estimateDisparitySettings.result()["1234"][itmNumberOfDisparities].asInt();

NxLibItem stereoMatching = camera[itmParameters][itmDisparityMap][itmStereoMatching];

stereoMatching[itmMinimumDisparity] = minDisp;
stereoMatching[itmNumberOfDisparities] = numDisps;

Note

cmdEstimateDisparitySettings works on the current raw images of this camera. So before using it, execute a capture command or set the binary nodes manually.