gen_binocular_rectification_map ( : Map1, Map2 : CamParam1, CamParam2, RelPose, SubSampling, Method, Interpolation : CamParamRect1, CamParamRect2, CamPoseRect1, CamPoseRect2, RelPoseRect )
Generate transformation maps that describe the mapping of the images of a
binocular camera pair to a common rectified image plane.
Given a pair of stereo images, rectification determines a
transformation of each image plane in a way that pairs of conjugate
epipolar lines become collinear and parallel to the horizontal image
axes. The rectified epipolar images can be thought of as acquired by
a new stereo rig, obtained by rotating the original cameras. The
camera centers of this virtual rig are maintained whereas the image
planes coincide, which means that the focal lengths are set equal,
and the optical axes parallel.
To achieve the transformation map for epipolar images
gen_binocular_rectification_map requires the internal camera
parameters CamParam1 of camera 1 and CamParam2 of
camera 2, as well as the relative pose RelPose defining a point
transformation from camera 2 to camera 1. These parameters
can be obtained, e.g., from
the operator binocular_calibration.
The projection onto a common plane has many degrees of freedom which
are implicitly restricted by selecting a certain method in
Method (currently only one method available):
'geometric' specifies the orientation of the common image
plane by the cross product of the base line and the line of
intersection of the original image planes. The new focal lengths of
the rectified cameras are determined in such a way as the old prinzipal
points have the same distance to the new common image plane.
Similar to gen_image_to_world_plane_map the parameter
Interpolation specifies whether bilinear interpolation
('bilinear') should be applied between the pixels in the
input image or the gray value of the nearest neighboring pixel should be
taken ('none'). The size and resolution of the maps and of the
transformed images can be adjusted by the SubSampling parameter
which applies a sub-sampling factor to the original images.
The mapping functions for the images of camera 1 and camera 2 are
returned in the images Map1 and Map2. If
Interpolation is set to 'none', both maps consist
of one single-channel image which contains the linear coordinate of
the pixel of the respective input image that is the nearest neighbor
of the transformed coordinate. In case of bilinear interpolation,
each map contains one five-channel image. The first channel contains for
each pixel of the respective map the linear coordinate of the
pixel in the respective input image that is in the upper left
position with respect to the transformed coordinate. The remaining
four channels of each map contain the weights of the four
neighboring pixels of the transformed coordinates which are used for
the bilinear interpolation. The mapping of the channel numbers to
the neighboring pixels is as follows:
+---+---+
| 2 | 3 |
+---+---+
| 4 | 5 |
+---+---+
In addition, gen_binocular_rectification_map returns the
modified internal and external camera parameters of the rectified
stereo rig. CamParamRect1 and CamParamRect2
contain the modified internal parameters of camera 1 and camera 2,
respectively. The rotation of the rectified camera in relation to
the original camera is specified by CamPoseRect1 and
CamPoseRect2, respectively. Finally, RelPoseRect
returns the modified relative pose of the rectified camera system 2
in relation to the rectified camera system 1 defining a translation
in x only. Generally, the transformations are defined in a way that
the rectified camera 1 is left of the rectified camera 2. This means
that the optical center of camera 2 has a positive x coordinate of the
rectified coordinate system of camera 1.
Parameters
Map1 (output_object)
|
(multichannel-)image -> object : int4 / uint2
|
|
Image containing the mapping data of camera 1. |
Map2 (output_object)
|
(multichannel-)image -> object : int4 / uint2
|
|
Image containing the mapping data of camera 2. |
CamParam1 (input_control)
|
number-array -> real / integer
|
|
Internal parameters of camera 1. |
|
Number of elements: 8 |
CamParam2 (input_control)
|
number-array -> real / integer
|
|
Internal parameters of camera 2. |
|
Number of elements: 8 |
RelPose (input_control)
|
pose-array -> real / integer
|
|
Point transformation from camera 2 to camera 1. |
|
Number of elements: 7 |
SubSampling (input_control)
|
real -> real
|
|
Factor of sub sampling. |
|
Default value: 1.0 |
|
Suggested values: 0.5, 0.66, 1.0, 1.5, 2.0, 3.0, 4.0 |
Method (input_control)
|
string -> string
|
|
Type of rectification. |
|
Default value: 'geometric' |
|
List of values: 'geometric' |
Interpolation (input_control)
|
string -> string
|
|
Type of interpolation. |
|
Default value: 'bilinear' |
|
List of values: 'none', 'bilinear' |
CamParamRect1 (output_control)
|
number-array -> real / integer
|
|
Rectified internal parameters of camera 1. |
|
Number of elements: 8 |
CamParamRect2 (output_control)
|
number-array -> real / integer
|
|
Rectified internal parameters of camera 2. |
|
Number of elements: 8 |
CamPoseRect1 (output_control)
|
pose-array -> real / integer
|
|
Point transformation from the rectified camera 1 to
the original camera 1. |
|
Number of elements: 7 |
CamPoseRect2 (output_control)
|
pose-array -> real / integer
|
|
Point transformation from the rectified camera 1 to
the original camera 1. |
|
Number of elements: 7 |
RelPoseRect (output_control)
|
pose-array -> real / integer
|
|
Point transformation from the rectified camera 2 to
the rectified camera 1. |
|
Number of elements: 7 |
Example
// ...
// read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
// the stereo images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose,
'geometric', 'bilinear', CamParRect1,
CamParamRect2, Cam1PoseRect1, Cam2PoseRect2,
RelPoseRect)
while 1
grab_image_async (Image1, FGHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, FGHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad',
11, 11, 20, -40, 20, 2, 25, 'left_right_check',
'interpolation')
endwhile
Result
gen_binocular_rectification_map returns 2 (H_MSG_TRUE) if all parameter values
are correct. If necessary, an exception handling is raised.
Parallelization Information
gen_binocular_rectification_map is reentrant and processed without parallelization.
Possible Predecessors
binocular_calibration
Possible Successors
map_image
Alternatives
gen_image_to_world_plane_map
See also
map_image,
gen_image_to_world_plane_map,
contour_to_world_plane_xld,
image_points_to_world_plane
Module
3D Metrology
Copyright © 1996-2008 MVTec Software GmbH