Operator Reference

binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms (Operator)

binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms — Compute the disparities of a rectified stereo image pair using multi-scanline optimization.

Signature

Herror binocular_disparity_ms(const Hobject ImageRect1, const Hobject ImageRect2, Hobject* Disparity, Hobject* Score, const Hlong MinDisparity, const Hlong MaxDisparity, const Hlong SurfaceSmoothing, const Hlong EdgeSmoothing, const char* GenParamName, const char* GenParamValue)

Herror T_binocular_disparity_ms(const Hobject ImageRect1, const Hobject ImageRect2, Hobject* Disparity, Hobject* Score, const Htuple MinDisparity, const Htuple MaxDisparity, const Htuple SurfaceSmoothing, const Htuple EdgeSmoothing, const Htuple GenParamName, const Htuple GenParamValue)

void BinocularDisparityMs(const HObject& ImageRect1, const HObject& ImageRect2, HObject* Disparity, HObject* Score, const HTuple& MinDisparity, const HTuple& MaxDisparity, const HTuple& SurfaceSmoothing, const HTuple& EdgeSmoothing, const HTuple& GenParamName, const HTuple& GenParamValue)

HImage HImage::BinocularDisparityMs(const HImage& ImageRect2, HImage* Score, Hlong MinDisparity, Hlong MaxDisparity, Hlong SurfaceSmoothing, Hlong EdgeSmoothing, const HTuple& GenParamName, const HTuple& GenParamValue) const

HImage HImage::BinocularDisparityMs(const HImage& ImageRect2, HImage* Score, Hlong MinDisparity, Hlong MaxDisparity, Hlong SurfaceSmoothing, Hlong EdgeSmoothing, const HString& GenParamName, const HString& GenParamValue) const

HImage HImage::BinocularDisparityMs(const HImage& ImageRect2, HImage* Score, Hlong MinDisparity, Hlong MaxDisparity, Hlong SurfaceSmoothing, Hlong EdgeSmoothing, const char* GenParamName, const char* GenParamValue) const

HImage HImage::BinocularDisparityMs(const HImage& ImageRect2, HImage* Score, Hlong MinDisparity, Hlong MaxDisparity, Hlong SurfaceSmoothing, Hlong EdgeSmoothing, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

def binocular_disparity_ms(image_rect_1: HObject, image_rect_2: HObject, min_disparity: int, max_disparity: int, surface_smoothing: int, edge_smoothing: int, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[str]) -> Tuple[HObject, HObject]

Description

binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms calculates the disparity between two rectified stereo images ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 and ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 using multi-scanline optimization. The resulting disparity image is returned in DisparityDisparityDisparitydisparitydisparity. In contrast to binocular_distance_msbinocular_distance_msBinocularDistanceMsBinocularDistanceMsbinocular_distance_ms, the results are not transformed into distance values.

For this task, the three operators binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity, binocular_disparity_mgbinocular_disparity_mgBinocularDisparityMgBinocularDisparityMgbinocular_disparity_mg, and binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms can be used. binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity returns robust results in regions of sufficient texture but fails where there is none. binocular_disparity_mgbinocular_disparity_mgBinocularDisparityMgBinocularDisparityMgbinocular_disparity_mg interpolates low-texture regions but blurs discontinuities. binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms preserves discontinuities and interpolates partially.

binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms requires a reference image ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 and a search image ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 which both must be rectified, i.e., corresponding pixels must have the same row coordinate. If this assumption is violated, the images can be rectified by using the operators calibrate_camerascalibrate_camerasCalibrateCamerasCalibrateCamerascalibrate_cameras, gen_binocular_rectification_mapgen_binocular_rectification_mapGenBinocularRectificationMapGenBinocularRectificationMapgen_binocular_rectification_map, and map_imagemap_imageMapImageMapImagemap_image.

ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 and ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 can have different widths but must have the same height. Given a pixel in ImageRect1ImageRect1ImageRect1imageRect1image_rect_1, the homologous pixel in ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 is selected by searching along the corresponding row in ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 and matching both pixels based on a similarity measure. The disparity is the number of pixels by which each pixel in ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 needs to be moved to reach the homologous pixel in ImageRect2ImageRect2ImageRect2imageRect2image_rect_2.

The search space is confined by the minimum and maximum disparity values MinDisparityMinDisparityMinDisparityminDisparitymin_disparity and MaxDisparityMaxDisparityMaxDisparitymaxDisparitymax_disparity. If the minimum and maximum disparity values are set to an empty tuple, they are automatically set to the maximum possible range for the given images ImageRect1ImageRect1ImageRect1imageRect1image_rect_1.

To calculate the disparities from the similarity measure, the intermediate results are optimized by a multi-scanline method. The optimization increases the robustness in low-texture areas without blurring discontinuities in the disparity image. The optimization is controlled by the parameters SurfaceSmoothingSurfaceSmoothingSurfaceSmoothingsurfaceSmoothingsurface_smoothing and EdgeSmoothingEdgeSmoothingEdgeSmoothingedgeSmoothingedge_smoothing. SurfaceSmoothingSurfaceSmoothingSurfaceSmoothingsurfaceSmoothingsurface_smoothing controls the smoothness within surfaces. High values suppress disparity differences of one pixel. EdgeSmoothingEdgeSmoothingEdgeSmoothingedgeSmoothingedge_smoothing controls the occurrence and the shape of edges. Low values allow many edges, high values lead to fewer and rounder edges. For both parameters, reasonable values usually range between 0 and 100. If both parameters are set to zero, no optimization is performed.

The calculation of the disparities can be controlled by generic parameters. The following generic parameters GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and the corresponding values GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value are supported:

'consistency_check'"consistency_check""consistency_check""consistency_check""consistency_check"

Activates an optional post-processing step to increase robustness. Concurrent direct and reverse matches between reference patterns in ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 and ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 are required for a disparity value to be returned. The check is switched off by setting GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value to 'false'"false""false""false""false".

List of values: 'true'"true""true""true""true", 'false'"false""false""false""false".

Default: 'true'"true""true""true""true".

'disparity_offset'"disparity_offset""disparity_offset""disparity_offset""disparity_offset"

Adapts the quality of the coarse-to-fine approach at discontinuities. The higher the value set in GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value, the more runtime is required.

Suggested values: 2, 3, 4.

Default: 3.

'method'"method""method""method""method":

Determines the method used to calculate the disparities. The following parameters GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value can be set:

The runtime of the operator is approximately linear to the image width, the image height, and the disparity range. Consequently, the disparity range should be chosen as narrow as possible for large images. The runtime of the coarse-to-fine scheme (which is used for 'fast'"fast""fast""fast""fast" or 'very_fast'"very_fast""very_fast""very_fast""very_fast") is approximately linear to the image width and the image height. For small images and small disparity ranges the runtime of the coarse-to-fine scheme may be larger than that of the 'accurate'"accurate""accurate""accurate""accurate" scheme.

List of values: 'accurate'"accurate""accurate""accurate""accurate", 'fast'"fast""fast""fast""fast", 'very_fast'"very_fast""very_fast""very_fast""very_fast".

Default: 'accurate'"accurate""accurate""accurate""accurate".

'num_levels'"num_levels""num_levels""num_levels""num_levels":

Determines the number of pyramid levels that are used for the coarse-to-fine scheme. By setting GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value to 'auto'"auto""auto""auto""auto", the number of pyramid levels is automatically calculated.

Suggested values: 2, 3, 'auto'"auto""auto""auto""auto".

Default: 'auto'"auto""auto""auto""auto".

'similarity_measure'"similarity_measure""similarity_measure""similarity_measure""similarity_measure":

Sets the similarity measure to be used. For both options 'census_dense'"census_dense""census_dense""census_dense""census_dense" (default) and 'census_sparse'"census_sparse""census_sparse""census_sparse""census_sparse", the similarity measure is based on the Census transform. A Census transformed image contains for every pixel information about the intensity topology within a support window around it.

  • 'census_dense'"census_dense""census_dense""census_dense""census_dense": Uses a dense 9 x 7 pixels window and is more suitable for fine structures.

  • 'census_sparse'"census_sparse""census_sparse""census_sparse""census_sparse": Uses a sparse 15 x 15 pixels window where only a subset of the pixels is evaluated. Is more robust in low-texture areas.

List of values: 'census_dense'"census_dense""census_dense""census_dense""census_dense", 'census_sparse'"census_sparse""census_sparse""census_sparse""census_sparse".

Default: 'census_dense'"census_dense""census_dense""census_dense""census_dense".

'sub_disparity'"sub_disparity""sub_disparity""sub_disparity""sub_disparity":

Activates sub-pixel refinement of disparities when set to 'true'"true""true""true""true". Can be deactivated by setting 'false'"false""false""false""false".

List of values: 'true'"true""true""true""true", 'false'"false""false""false""false".

Default: 'true'"true""true""true""true".

The resulting disparity is returned in the single-channel image DisparityDisparityDisparitydisparitydisparity. A quality measure for each disparity value is returned in ScoreScoreScorescorescore, containing the best (lowest) result of the optimized similarity measure of a reference pixel.

Execution Information

  • Supports OpenCL compute devices.
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Automatically parallelized on tuple level.
  • Automatically parallelized on internal data level.

Parameters

ImageRect1ImageRect1ImageRect1imageRect1image_rect_1 (input_object)  singlechannelimage objectHImageHObjectHObjectHobject (byte*) *allowed for compute devices

Rectified image of camera 1.

ImageRect2ImageRect2ImageRect2imageRect2image_rect_2 (input_object)  singlechannelimage objectHImageHObjectHObjectHobject (byte*) *allowed for compute devices

Rectified image of camera 2.

DisparityDisparityDisparitydisparitydisparity (output_object)  singlechannelimage objectHImageHObjectHObjectHobject * (real)

Disparity map.

ScoreScoreScorescorescore (output_object)  singlechannelimage objectHImageHObjectHObjectHobject * (real)

Score of the calculated disparity.

MinDisparityMinDisparityMinDisparityminDisparitymin_disparity (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Minimum of the expected disparities.

Default: -30

Value range: -32768 ≤ MinDisparity MinDisparity MinDisparity minDisparity min_disparity ≤ 32768

Restriction: MinDisparity <= MaxDisparity

MaxDisparityMaxDisparityMaxDisparitymaxDisparitymax_disparity (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Maximum of the expected disparities.

Default: 30

Value range: -32768 ≤ MaxDisparity MaxDisparity MaxDisparity maxDisparity max_disparity ≤ 32768

Restriction: MinDisparity <= MaxDisparity

SurfaceSmoothingSurfaceSmoothingSurfaceSmoothingsurfaceSmoothingsurface_smoothing (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Smoothing of surfaces.

Default: 50

Suggested values: 20, 50, 100

Restriction: SurfaceSmoothing >= 0

EdgeSmoothingEdgeSmoothingEdgeSmoothingedgeSmoothingedge_smoothing (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Smoothing of edges.

Default: 50

Suggested values: 20, 50, 100

Restriction: EdgeSmoothing >= 0

GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Parameter name(s) for the multi-scanline algorithm.

Default: []

List of values: 'consistency_check'"consistency_check""consistency_check""consistency_check""consistency_check", 'disparity_offset'"disparity_offset""disparity_offset""disparity_offset""disparity_offset", 'method'"method""method""method""method", 'num_levels'"num_levels""num_levels""num_levels""num_levels", 'similarity_measure'"similarity_measure""similarity_measure""similarity_measure""similarity_measure", 'sub_disparity'"sub_disparity""sub_disparity""sub_disparity""sub_disparity"

GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.value(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Parameter value(s) for the multi-scanline algorithm.

Default: []

Suggested values: 'accurate'"accurate""accurate""accurate""accurate", 'fast'"fast""fast""fast""fast", 'very_fast'"very_fast""very_fast""very_fast""very_fast", 'census_dense'"census_dense""census_dense""census_dense""census_dense", 'census_sparse'"census_sparse""census_sparse""census_sparse""census_sparse", 'true'"true""true""true""true", 'false'"false""false""false""false", 'auto'"auto""auto""auto""auto"

Example (HDevelop)

read_image (BaseballL, 'stereo/epipolar/baseball_l')
read_image (BaseballR, 'stereo/epipolar/baseball_r')
binocular_disparity_ms (BaseballL, BaseballR, Disparity, Score, \
                        -40, -10, 50, 50, [], [])

Result

If the parameter values are correct, binocular_disparity_msbinocular_disparity_msBinocularDisparityMsBinocularDisparityMsbinocular_disparity_ms returns the value 2 ( H_MSG_TRUE) . If the input is empty (no input images are available) the behavior can be set via set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>). If necessary, an exception is raised.

Possible Predecessors

map_imagemap_imageMapImageMapImagemap_image

Possible Successors

thresholdthresholdThresholdThresholdthreshold, disparity_to_distancedisparity_to_distanceDisparityToDistanceDisparityToDistancedisparity_to_distance, disparity_image_to_xyzdisparity_image_to_xyzDisparityImageToXyzDisparityImageToXyzdisparity_image_to_xyz

Alternatives

binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity, binocular_disparity_mgbinocular_disparity_mgBinocularDisparityMgBinocularDisparityMgbinocular_disparity_mg, binocular_distancebinocular_distanceBinocularDistanceBinocularDistancebinocular_distance, binocular_distance_mgbinocular_distance_mgBinocularDistanceMgBinocularDistanceMgbinocular_distance_mg, binocular_distance_msbinocular_distance_msBinocularDistanceMsBinocularDistanceMsbinocular_distance_ms

See also

map_imagemap_imageMapImageMapImagemap_image, gen_binocular_rectification_mapgen_binocular_rectification_mapGenBinocularRectificationMapGenBinocularRectificationMapgen_binocular_rectification_map, binocular_calibrationbinocular_calibrationBinocularCalibrationBinocularCalibrationbinocular_calibration

Module

3D Metrology