binocular_calibration ( : : NX, NY, NZ, NRow1, NCol1, NRow2, NCol2, StartCamParam1, StartCamParam2, NStartPose1, NStartPose2, EstimateParams : CamParam1, CamParam2, NFinalPose1, NFinalPose2, RelPose, Errors )
Determine all camera parameters of a binocular stereo system.
In general, binocular calibration means the exact determination of
the parameters that model the 3D reconstruction of a 3D point
from the corresponding images of this point in a binocular stereo
system. This reconstruction is specified by the internal parameters
CamParam1 of camera 1 and CamParam2 of camera 2
describing the underlying camera model, and the external parameters
RelPose describing the relative pose of camera system 2 in
relation to camera system 1.
Thus, known 3D model points (with coordinates NX,
NY, NZ) are projected in the image planes of both
cameras (camera 1 and camera 2) and the sum of the squared distances
between these projections and the corresponding measured image
points (with coordinates NRow1, NCol1 for camera 1
and NRow2, NCol2 for camera 2) is minimized. It
should be noted that all these model points must be visible in both
images. The projection uses the initial values
StartCamParam1 and StartCamParam2 of the internal
parameters of camera 1 and camera 2 which can be obtained from the
camera data sheets. In addition, the initial guesses
NStartPose1 and NStartPose2 of the poses of the 3D
calibration model in relation to the camera coordinate systems (CCS)
of camera 1 and camera 2 are needed as well. These 3D transformation
poses can be determined by the find_marks_and_pose
operator. Since this calibration algorithm simultaneously handles
correspondences between measured image and known model points from
different image pairs, poses (NStartPose1,NStartPose2),
and measured points (NRow1,NCol1,NRow2,
NCol2) must be passed concatenated in a corresponding order.
The input parameter EstimateParams is used to select the
parameters to be estimated. Usually this parameter is set to 'all',
i.e., all external camera parameters (translation and rotation) and
all internal camera parameters are determined. Otherwise,
EstimateParams contains a tuple of strings indicating the
combination of parameters to estimate. For instance, if the interior camera
parameters already have been determined (e.g., by previous calls to
camera_calibration) it is often desired to only determine relative
the pose of the two cameras to each other (RelPose). In this case,
EstimateParams can be set to 'pose_rel'. This has the
same effect as EstimateParams = ['pose1','pose2'].
The internal parameters can be subsumed by the parameter values
'cam_param1' and 'cam_param2', as well. In addition,
parameters can be excluded from estimation by using the prefix
~. For example, the values
['pose1', '~transx1'] have the same effect as
['alpha1','beta1','gamma1','transy1','transz1'].
Whereas
['all','~focus1']
determines all internal
and external parameters except the focus of camera 1, for instance.
The prefix ~ can be used with all parameter values
except 'all'.
The underlying camera model is explained in the description of the
camera_calibration operator. It is specified by the
parameters [focus1, kappa1, sx1, sy1, cx1, cy1, image_width1,
image_height1] of camera 1 returned in CamParam1 and
[focus2, kappa2, sx2, sy2, cx2, cy2, image_width2, image_height2]
of camera 2 (CamParam2). The external parameters
[alpha_rel, beta_rel, gamma_rel, transx_rel, transy_rel,
transz_rel] are returned in RelPose and specify the 3D
transformation of points of CCS 2 into CCS 1. Note that according to
the description of poses at create_pose one parameter is
appended to the pose tuple at the last position to define the
representation type of this pose.
According to camera_calibration the 3D transformation poses
of the calibration model to the respective CCS are returned in
NFinalPose1 and NFinalPose2. These transformations
are related to RelPose according to the following equation
(neglecting differences due to the balancing effects of the multi image
calibration):
HomMat3D_NFinalPose2 = INV(HomMat3D_RelPose) * HomMat3D_NFinalPose1 ,
whereas HomMat3D_* denotes a homogeneous transformation matrix of
the respective poses and INV() inverts a homogeneous matrix.
The computed average errors returned in Errors give an
impression of the accuracy of the calibration. Using the determined camera
parameters they denote the average of
the euklidean distance of the projection of the mark centers of the model
to their image.
Parameters
NX (input_control)
|
real-array -> real
|
|
Ordered Tuple with all X-coordinates
of the calibration marks (in meters). |
NY (input_control)
|
real-array -> real
|
|
Ordered Tuple with all Y-coordinates
of the calibration marks (in meters). |
NZ (input_control)
|
real-array -> real
|
|
Ordered Tuple with all Z-coordinates
of the calibration marks (in meters). |
NRow1 (input_control)
|
real-array -> real
|
|
Ordered Tuple with all row-coordinates
of the extracted calibration marks of camera 1
(in pixels). |
NCol1 (input_control)
|
real-array -> real
|
|
Ordered Tuple with all column-coordinates
of the extracted calibration marks of camera 1
(in pixels). |
NRow2 (input_control)
|
real-array -> real
|
|
Ordered Tuple with all row-coordinates
of the extracted calibration marks of camera 2
(in pixels). |
NCol2 (input_control)
|
real-array -> real
|
|
Ordered Tuple with all column-coordinates
of the extracted calibration marks of camera 2
(in pixels). |
StartCamParam1 (input_control)
|
real-array -> real / integer
|
|
Initial values for the internal parameters of
camera 1. |
StartCamParam2 (input_control)
|
real-array -> real / integer
|
|
Initial values for the internal parameters of
camera 2. |
NStartPose1 (input_control)
|
pose-array -> real / integer
|
|
Ordered tuple with all initial values for the
poses of the calibration model in relation to
camera 1. |
NStartPose2 (input_control)
|
pose-array -> real / integer
|
|
Ordered tuple with all initial values for the
poses of the calibration model in relation to
camera 2. |
EstimateParams (input_control)
|
string(-array) -> string / integer
|
|
Camera parameters to be estimated. |
|
Default value: 'all' |
|
List of values: 'all', 'pose_rel', 'pose1', 'pose2', 'cam_param1', 'cam_param2', 'alpha1', 'beta1', 'gamma1', 'transx1', 'transy1', 'transz1', 'alpha2', 'beta2', 'gamma2', 'transx2', 'transy2', 'transz2', 'focus1', 'kappa1', 'cx1', 'cy1', 'sx1', 'sy1', 'focus2', 'kappa2', 'cx2', 'cy2', 'sx2', 'sy2' |
CamParam1 (output_control)
|
number-array -> real / integer
|
|
Internal parameters of camera 1. |
CamParam2 (output_control)
|
number-array -> real / integer
|
|
Internal parameters of camera 2. |
NFinalPose1 (output_control)
|
pose-array -> real / integer
|
|
Ordered tuple with all poses of the calibration model
in relation to camera 1. |
NFinalPose2 (output_control)
|
pose-array -> real / integer
|
|
Ordered tuple with all poses of the calibration model
in relation to camera 2. |
RelPose (output_control)
|
pose-array -> real / integer
|
|
Pose of camera 2 in relation to camera 1. |
Errors (output_control)
|
real-array -> real
|
|
Average error distances in pixels. |
Example
// open image source
close_all_framegrabbers ()
open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1,
'default', 'images_l.seq', 'default', 0, -1, FGHandle1)
open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1,
'default', 'images_r.seq', 'default', 1, -1, FGHandle2)
// initialize the start parameters
create_caltab (0.03, 'caltab_30.descr', 'caltab_30.ps')
caltab_points ('caltab_30.descr', X, Y, Z)
StartCamParam1 := [0.0125, 0, 7.4e-6, 7.4e-6,Width/2.0,Height/2.0,Width,Height]
StartCamParam2 := StartCamParam1
Rows1 := []
Cols1 := []
StartPoses1 := []
Rows2 := []
Cols2 := []
StartPoses2 := []
// find calibration marks and startposes
for i := 0 to 11 by 1
grab_image_async (Image1, FGHandle1, -1)
grab_image_async (Image2, FGHandle2, -1)
find_caltab (Image1, Caltab1, 'caltab_30.descr', 3, 120, 5)
find_caltab (Image2, Caltab2, 'caltab_30.descr', 3, 120, 5)
find_marks_and_pose (Image1, Caltab1, 'caltab_30.descr', StartCamParam1,
128, 10, 20, 0.7, 5, 100, RCoord1, CCoord1,
StartPose1)
Rows1 := [Rows1,RCoord1]
Cols1 := [Cols1,CCoord1]
StartPoses1 := [StartPoses1,StartPose1]
find_marks_and_pose (Image2, Caltab2, 'caltab_30.descr', StartCamParam2,
128, 10, 20, 0.7, 5, 100, RCoord2, CCoord2,
StartPose2)
Rows2 := [Rows2,RCoord2]
Cols2 := [Cols2,CCoord2]
StartPoses2 := [StartPoses2,StartPose2]
endfor
// calibrate the stereo rig
binocular_calibration (X, Y, Z, Rows1, Cols1, Rows2, Cols2, StartCamParam1,
StartCamParam2, StartPoses1, StartPoses2, 'all',
CamParam1, CamParam2, NFinalPose1, NFinalPose2,
RelPose, Errors)
// archive the results
write_cam_par (CamParam1, 'cam_left-125.dat')
write_cam_par (CamParam2, 'cam_right-125.dat')
write_pose (RelPose, 'rel_pose.dat')
// ... rectify the stereo images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose,
'geometric', 'bilinear', CamParamRect1, CamParamRect2, Cam1PoseRect1,
Cam2PoseRect2, RelPoseRect)
map_image (Image1, Map1, ImageMapped1)
map_image (Image2, Map2, ImageMapped2)
Result
binocular_calibration returns 2 (H_MSG_TRUE) if all parameter values are
correct and the desired parameters have been determined by the
minimization algorithm. If necessary, an exception handling is raised.
Parallelization Information
binocular_calibration is reentrant and processed without parallelization.
Possible Predecessors
find_marks_and_pose,
caltab_points,
read_cam_par
Possible Successors
write_pose,
write_cam_par,
pose_to_hom_mat3d,
disp_caltab,
gen_binocular_rectification_map
See also
find_caltab,
sim_caltab,
read_cam_par,
create_pose,
convert_pose_type,
read_pose,
hom_mat3d_to_pose,
create_caltab,
binocular_disparity,
binocular_distance
Module
3D Metrology
Copyright © 1996-2008 MVTec Software GmbH