binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity — Compute the disparities of a rectified image pair using correlation
techniques.
The used matching function is defined by the parameter
MethodMethodMethodmethodmethod allocating three different kinds of correlation:
'sad'"sad""sad""sad""sad": Summed Absolute Differences
with .
'ssd'"ssd""ssd""ssd""ssd": Summed Squared Differences
with .
'ncc'"ncc""ncc""ncc""ncc": Normalized Cross Correlation
with .
with
, , , :
row and column coordinates of the corresponding
pixels of the two input images,
, : gray values of the unprocessed input images,
: size of correlation window
: mean value within the correlation window of width
and height .
Note that the methods 'sad'"sad""sad""sad""sad" and 'ssd'"ssd""ssd""ssd""ssd" compare the
gray values of the pixels within a mask window directly, whereas
'ncc'"ncc""ncc""ncc""ncc" compensates for the mean gray value and its variance
within the mask window. Therefore, if the two images differ in
brightness and contrast, this method should be preferred. For images
with similar brightness and contrast 'sad'"sad""sad""sad""sad" and
'ssd'"ssd""ssd""ssd""ssd" are to be preferred as they are faster because of
less complex internal computations.
It should be noted, that the quality of correlation for rising
is falling in methods 'sad'"sad""sad""sad""sad" and 'ssd'"ssd""ssd""ssd""ssd"
(the best quality value is 0) but rising in method 'ncc'"ncc""ncc""ncc""ncc"
(the best quality value is 1.0).
The number of pyramid levels used to improve the time response of
binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity is determined by
NumLevelsNumLevelsNumLevelsnumLevelsnum_levels. Following a coarse-to-fine scheme disparity
images of higher levels are computed and segmented into rectangular
subimages of similar disparity to reduce the disparity range on the
next lower pyramid level. TextureThreshTextureThreshTextureThreshtextureThreshtexture_thresh and
ScoreThreshScoreThreshScoreThreshscoreThreshscore_thresh are applied on every level and the returned
domain of the DisparityDisparityDisparitydisparitydisparity and ScoreScoreScorescorescore images arises
from the intersection of the resulting domains of every single
level. Generally, pyramid structures are the more advantageous the
more the disparity image can be segmented into regions of
homogeneous disparities and the bigger the disparity range is
specified. As a drawback, coarse pyramid levels might loose
important texture information which can result in deficient
disparity values.
Finally, the value 'interpolation'"interpolation""interpolation""interpolation""interpolation" for parameter
SubDisparitySubDisparitySubDisparitysubDisparitysub_disparity performs subpixel refinement of
disparities. It is switched off by setting the parameter to
'none'"none""none""none""none".
Execution Information
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Automatically parallelized on internal data level.
List of values:
'interpolation'"interpolation""interpolation""interpolation""interpolation", 'none'"none""none""none""none"
Example (HDevelop)
* Set internal and external stereo parameters.
* Note that, typically, these values are the result of a prior
* calibration.
gen_cam_par_area_scan_division (0.01, -665, 5.2e-006, 5.2e-006, \
622, 517, 1280, 1024, CamParam1)
gen_cam_par_area_scan_division (0.01, -731, 5.2e-006, 5.2e-006, \
654, 519, 1280, 1024, CamParam2)
create_pose (0.1535,-0.0037,0.0447,0.17,319.84,359.89, \
'Rp+T', 'gba', 'point', RelPose)
* Compute the mapping for rectified images.
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'viewing_direction', 'bilinear', \
CamParamRect1,CamParamRect2, \
Cam1PoseRect1, Cam2PoseRect2,RelPoseRect)
* Compute the disparities in online images.
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageRect1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageRect2)
binocular_disparity(ImageRect1, ImageRect2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check', \
'interpolation')
endwhile
Example (HDevelop)
* Set internal and external stereo parameters.
* Note that, typically, these values are the result of a prior
* calibration.
gen_cam_par_area_scan_division (0.01, -665, 5.2e-006, 5.2e-006, \
622, 517, 1280, 1024, CamParam1)
gen_cam_par_area_scan_division (0.01, -731, 5.2e-006, 5.2e-006, \
654, 519, 1280, 1024, CamParam2)
create_pose (0.1535,-0.0037,0.0447,0.17,319.84,359.89, \
'Rp+T', 'gba', 'point', RelPose)
* Compute the mapping for rectified images.
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'viewing_direction', 'bilinear', \
CamParamRect1,CamParamRect2, \
Cam1PoseRect1, Cam2PoseRect2,RelPoseRect)
* Compute the disparities in online images.
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageRect1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageRect2)
binocular_disparity(ImageRect1, ImageRect2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check', \
'interpolation')
endwhile
Example (C++)
// Set internal and external stereo parameters.
// Note that, typically, these values are the result of a prior
// calibration.
gen_cam_par_area_scan_division (0.01, -665, 5.2e-006, 5.2e-006,
622, 517, 1280, 1024, &CamParam1);
gen_cam_par_area_scan_division (0.01, -731, 5.2e-006, 5.2e-006,
654, 519, 1280, 1024, &CamParam2);
create_pose (0.1535,-0.0037,0.0447,0.17,319.84,359.89,
"Rp+T", "gba", "point", &RelPose);
// Compute the mapping for rectified images.
gen_binocular_rectification_map(&Map1,&Map2,CamParam1,CamParam2,RelPose,1,
"viewing_direction","bilinear",
&CamParamRect1,&CamParamRect2,
&CamPoseRect1,&CamPoseRect2,&RelPosRect);
// Compute the disparities in online images.
while (1)
{
grab_image_async(&Image1,AcqHandle1,-1);
map_image(Image1,Map1,&ImageRect1);
grab_image_async(&Image2,AcqHandle2,-1);
map_image(Image2,Map2,&ImageRect2);
binocular_disparity(ImageRect1,ImageRect2,&Disparity,&Score,"sad",
11,11,20,-40,20,2,25,"left_right_check",
"interpolation");
}
Example (HDevelop)
* Set internal and external stereo parameters.
* Note that, typically, these values are the result of a prior
* calibration.
gen_cam_par_area_scan_division (0.01, -665, 5.2e-006, 5.2e-006, \
622, 517, 1280, 1024, CamParam1)
gen_cam_par_area_scan_division (0.01, -731, 5.2e-006, 5.2e-006, \
654, 519, 1280, 1024, CamParam2)
create_pose (0.1535,-0.0037,0.0447,0.17,319.84,359.89, \
'Rp+T', 'gba', 'point', RelPose)
* Compute the mapping for rectified images.
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'viewing_direction', 'bilinear', \
CamParamRect1,CamParamRect2, \
Cam1PoseRect1, Cam2PoseRect2,RelPoseRect)
* Compute the disparities in online images.
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageRect1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageRect2)
binocular_disparity(ImageRect1, ImageRect2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check', \
'interpolation')
endwhile
Result
binocular_disparitybinocular_disparityBinocularDisparityBinocularDisparitybinocular_disparity returns 2 (
H_MSG_TRUE)
if all parameter values are
correct. If necessary, an exception is raised.