Name
radial_distortion_self_calibration T_radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration — Calibrate the radial distortion.
Herror radial_distortion_self_calibration (Hobject Contours , Hobject* SelectedContours , const HTuple& Width , const HTuple& Height , const HTuple& InlierThreshold , const HTuple& RandSeed , const HTuple& DistortionModel , const HTuple& DistortionCenter , const HTuple& PrincipalPointVar , HTuple* CameraParam )
HXLDContArray HXLDContArray ::RadialDistortionSelfCalibration (const HTuple& Width , const HTuple& Height , const HTuple& InlierThreshold , const HTuple& RandSeed , const HTuple& DistortionModel , const HTuple& DistortionCenter , const HTuple& PrincipalPointVar , HTuple* CameraParam ) const
void RadialDistortionSelfCalibration (const HObject& Contours , HObject* SelectedContours , const HTuple& Width , const HTuple& Height , const HTuple& InlierThreshold , const HTuple& RandSeed , const HTuple& DistortionModel , const HTuple& DistortionCenter , const HTuple& PrincipalPointVar , HTuple* CameraParam )
HXLDCont HXLDCont ::RadialDistortionSelfCalibration (Hlong Width , Hlong Height , double InlierThreshold , Hlong RandSeed , const HString& DistortionModel , const HString& DistortionCenter , double PrincipalPointVar , HCamPar* CameraParam ) const
HXLDCont HXLDCont ::RadialDistortionSelfCalibration (Hlong Width , Hlong Height , double InlierThreshold , Hlong RandSeed , const char* DistortionModel , const char* DistortionCenter , double PrincipalPointVar , HCamPar* CameraParam ) const
HXLDCont HCamPar ::RadialDistortionSelfCalibration (const HXLDCont& Contours , Hlong Width , Hlong Height , double InlierThreshold , Hlong RandSeed , const HString& DistortionModel , const HString& DistortionCenter , double PrincipalPointVar )
HXLDCont HCamPar ::RadialDistortionSelfCalibration (const HXLDCont& Contours , Hlong Width , Hlong Height , double InlierThreshold , Hlong RandSeed , const char* DistortionModel , const char* DistortionCenter , double PrincipalPointVar )
void HOperatorSetX .RadialDistortionSelfCalibration ( [in] IHUntypedObjectX* Contours , [out] IHUntypedObjectX* * SelectedContours , [in] VARIANT Width , [in] VARIANT Height , [in] VARIANT InlierThreshold , [in] VARIANT RandSeed , [in] VARIANT DistortionModel , [in] VARIANT DistortionCenter , [in] VARIANT PrincipalPointVar , [out] VARIANT* CameraParam )
IHXLDContX* HXLDContX .RadialDistortionSelfCalibration ( [in] Hlong Width , [in] Hlong Height , [in] double InlierThreshold , [in] Hlong RandSeed , [in] BSTR DistortionModel , [in] BSTR DistortionCenter , [in] double PrincipalPointVar , [out] VARIANT* CameraParam )
IHXLDContX* HCamParX .RadialDistortionSelfCalibration ( [in] IHXLDContX* Contours , [in] Hlong Width , [in] Hlong Height , [in] double InlierThreshold , [in] Hlong RandSeed , [in] BSTR DistortionModel , [in] BSTR DistortionCenter , [in] double PrincipalPointVar , [out] VARIANT* CameraParam )
static void HOperatorSet .RadialDistortionSelfCalibration (HObject contours , out HObject selectedContours , HTuple width , HTuple height , HTuple inlierThreshold , HTuple randSeed , HTuple distortionModel , HTuple distortionCenter , HTuple principalPointVar , out HTuple cameraParam )
HXLDCont HXLDCont .RadialDistortionSelfCalibration (int width , int height , double inlierThreshold , int randSeed , string distortionModel , string distortionCenter , double principalPointVar , out HCamPar cameraParam )
HXLDCont HCamPar .RadialDistortionSelfCalibration (HXLDCont contours , int width , int height , double inlierThreshold , int randSeed , string distortionModel , string distortionCenter , double principalPointVar )
radial_distortion_self_calibration radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration estimates the distortion
parameters and the distortion center of a lens from a set of XLD
Contours Contours Contours Contours Contours contours .
The distortion parameters are returned in CameraParam CameraParam CameraParam CameraParam CameraParam cameraParam .
Because no other parameters are estimated - particularly not the focal
length or the magnification - a telecentric camera model is returned with
Magnification Magnification Magnification Magnification Magnification magnification 1 and scale factor 1 for
and
.
See calibrate_cameras calibrate_cameras CalibrateCameras calibrate_cameras CalibrateCameras CalibrateCameras for more information on the different camera
models.
Application
Based on the result of radial_distortion_self_calibration radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration , you
can remove lens distortions from images by passing the parameter
CameraParam CameraParam CameraParam CameraParam CameraParam cameraParam , which contains the distortion parameters, to the
operators change_radial_distortion_cam_par change_radial_distortion_cam_par ChangeRadialDistortionCamPar change_radial_distortion_cam_par ChangeRadialDistortionCamPar ChangeRadialDistortionCamPar and
change_radial_distortion_image change_radial_distortion_image ChangeRadialDistortionImage change_radial_distortion_image ChangeRadialDistortionImage ChangeRadialDistortionImage .
Basic principle
The estimation of the distortions is based on the assumption that a
significant number of straight lines are visible in the image.
Because of lens distortions, these lines will
be projected to curved contours. The operator now determines suitable
parameters by which the curved contours can be straightened again, thus
compensating the lens distortions.
Extract input contours
To get suitable input contours Contours Contours Contours Contours Contours contours , you can, e.g., use
edges_sub_pix edges_sub_pix EdgesSubPix edges_sub_pix EdgesSubPix EdgesSubPix or lines_gauss lines_gauss LinesGauss lines_gauss LinesGauss LinesGauss .
The contours should be equally distributed
and should lie near the image border because there the degree of
distortion is at its maximum and therefore the calibration is most
stable. To improve speed and robustness, you can try to
to obtain long linear or circular segments, e.g., with
segment_contours_xld segment_contours_xld SegmentContoursXld segment_contours_xld SegmentContoursXld SegmentContoursXld , union_collinear_contours_xld union_collinear_contours_xld UnionCollinearContoursXld union_collinear_contours_xld UnionCollinearContoursXld UnionCollinearContoursXld ,
union_cocircular_contours_xld union_cocircular_contours_xld UnionCocircularContoursXld union_cocircular_contours_xld UnionCocircularContoursXld UnionCocircularContoursXld , or select_shape_xld select_shape_xld SelectShapeXld select_shape_xld SelectShapeXld SelectShapeXld .
If a single image does
not contain enough straight contours in the scene,
you can use the contours of multiple images (concat_obj concat_obj ConcatObj concat_obj ConcatObj ConcatObj ).
Set parameters for contour selection
The operator automatically estimates those contours from
Contours Contours Contours Contours Contours contours that are images of straigt lines in the scene using
the robust RANSAC method. The contours that do not fulfill this
condition and hence are not suited for the calibration process are
called outliers. The operator can cope with a maximum outlier
percentage of 50 percent. A contour is classified as an outlier if
the mean deviation of the contour from its associated straight line
is, after the distortion correction, higher than a given threshold
T.
The value InlierThreshold InlierThreshold InlierThreshold InlierThreshold InlierThreshold inlierThreshold describes the mean deviation of a
contour from its associated line in pixels for a contour that
contains 100 points. The actual threshold T is derived from
InlierThreshold InlierThreshold InlierThreshold InlierThreshold InlierThreshold inlierThreshold by scaling it with the reference length
(100) and the number of contour points m. Therefore, similar
contours are classified alike. Typical values of
InlierThreshold InlierThreshold InlierThreshold InlierThreshold InlierThreshold inlierThreshold range from 0.05 to 0.5. The higher the
value, the more deviation is tolerated. By choosing the value 0, all
the contours of Contours Contours Contours Contours Contours contours are used for the calibration
process. The RANSAC contour selection will then be suppressed to
enable a manual contour selection. This can be helpful if the
outlier percentage is higher than 50 percent.
With the parameter RandSeed RandSeed RandSeed RandSeed RandSeed randSeed , you can control the randomized
behavior of the RANSAC algorithm and force it to return reproducible
results. The parameter is passed as initial value to the internally
used random number generator. If it is set to a positive value, the
operator returns identical results for each call with identical
parameter values.
radial_distortion_self_calibration radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration returns the contours
that were chosen for the calibration process in SelectedContours SelectedContours SelectedContours SelectedContours SelectedContours selectedContours .
Select distortion model
The distortion model used in the calibration can be selected with
the parameter DistortionModel DistortionModel DistortionModel DistortionModel DistortionModel distortionModel . By choosing the division model
(DistortionModel DistortionModel DistortionModel DistortionModel DistortionModel distortionModel = 'division' "division" "division" "division" "division" "division" ), the distortions are
modeled by the distortion parameter
.
By choosing the polynomial model
(DistortionModel DistortionModel DistortionModel DistortionModel DistortionModel distortionModel = 'polynomial' "polynomial" "polynomial" "polynomial" "polynomial" "polynomial" ), the
distortions are modeled by the radial distortion parameters
and the decentering distortion
parameters
.
See calibrate_cameras calibrate_cameras CalibrateCameras calibrate_cameras CalibrateCameras CalibrateCameras for details on the different camera models.
Set parameters for the distortion center estimation
The starting value for the estimation of the distortion center
is the center of the image;
the image size is defined by Width Width Width Width Width width and Height Height Height Height Height height .
The distortion parameters
or
, respectively, are estimated via the
methods 'variable' "variable" "variable" "variable" "variable" "variable" , 'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" , or
'fixed' "fixed" "fixed" "fixed" "fixed" "fixed" , which are specified via the parameter
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter :
'variable'
In the default mode 'variable' "variable" "variable" "variable" "variable" "variable" ,
the distortion center c is estimated with all the other calibration
parameters at the same time. Here, many contours should lie equally
distributed near the image borders or the distortion should be high.
Otherwise, the search for the distortion center could be ill-posed,
which results in instability.
'adaptive'
With the method 'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" ,
the distortion center c is at first fixed in the image center.
Then, the outliers are eliminated by using the
InlierThreshold InlierThreshold InlierThreshold InlierThreshold InlierThreshold inlierThreshold . Finally, the calibration process is rerun
by estimating
or
, respectively, which will be accepted
if
results from a stable
calibration and lies near the image center. Otherwise, c will be
assumed to lie in the image center. This method should be used if
the distortion center can be assumed to lie near the image center
and if very few contours are available or the position of other
contours is bad (e.g., the contours have the same direction or lie
in the same image region).
'fixed'
By choosing the method 'fixed' "fixed" "fixed" "fixed" "fixed" "fixed" ,
the distortion center will be assumed fixed in the image center and
only
or
,
respectively, will be estimated. This method should be used in case of
very weak distortions or few contours in bad position.
In order to control the deviation of c from the image center, the
parameter PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar can be used in the methods
'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" and 'variable' "variable" "variable" "variable" "variable" "variable" . If the deviation from
the image center should be controlled, PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar
must lie between 1 and 100. The higher the value, the more the
distortion center can deviate from the image center. By choosing
the value 0, the principal point is not controlled, i.e., the
principal point is determined solely based on the contours. The
parameter PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar should be used in cases of weak
distortions or similarly oriented contours. Otherwise, a stable
solution cannot be guaranteed.
Runtime
The runtime of
radial_distortion_self_calibration radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration is shortest for
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'variable' "variable" "variable" "variable" "variable" "variable" and
PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar = 0 . The runtime for
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'variable' "variable" "variable" "variable" "variable" "variable" and
PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar > 0 increases significantly
for smaller values of PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar . The runtimes for
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" and
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'fixed' "fixed" "fixed" "fixed" "fixed" "fixed" are also
significantly higher than for DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter =
'variable' "variable" "variable" "variable" "variable" "variable" and PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar =
0 .
Since the polynomial model
(DistortionModel DistortionModel DistortionModel DistortionModel DistortionModel distortionModel = 'polynomial' "polynomial" "polynomial" "polynomial" "polynomial" "polynomial" ) uses more parameters
than the division model (DistortionModel DistortionModel DistortionModel DistortionModel DistortionModel distortionModel = 'division' "division" "division" "division" "division" "division" )
the calibration using the polynomial model can be slightly less stable than
the calibration using the division model, which becomes noticeable in the
accuracy of the decentering distortion parameters
.
To improve the stability, contours of multiple images can be used.
Additional stability can be achieved by setting
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'fixed' "fixed" "fixed" "fixed" "fixed" "fixed" ,
DistortionCenter DistortionCenter DistortionCenter DistortionCenter DistortionCenter distortionCenter = 'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" , or
PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar PrincipalPointVar principalPointVar > 0 , which was already mentioned
above.
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Processed without parallelization.
Contours that are available for the calibration.
Contours that were used for the calibration
Width of the images from which the contours
were extracted.
Default value: 640
Suggested values: 640, 768
Restriction: Width > 0
Height of the images from which the contours
were extracted.
Default value: 480
Suggested values: 480, 576
Restriction: Height > 0
Threshold for the classification of outliers.
Default value: 0.05
Suggested values: 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1
Restriction: InlierThreshold >= 0
Seed value for the random number generator.
Default value: 42
Determines the distortion model.
Default value:
'division'
"division"
"division"
"division"
"division"
"division"
List of values: 'division' "division" "division" "division" "division" "division" , 'polynomial' "polynomial" "polynomial" "polynomial" "polynomial" "polynomial"
Determines how the distortion center will be
estimated.
Default value:
'variable'
"variable"
"variable"
"variable"
"variable"
"variable"
List of values: 'adaptive' "adaptive" "adaptive" "adaptive" "adaptive" "adaptive" , 'fixed' "fixed" "fixed" "fixed" "fixed" "fixed" , 'variable' "variable" "variable" "variable" "variable" "variable"
Controls the deviation of the distortion center
from the image center; larger values allow
larger deviations from the image center; 0
switches the penalty term off.
Default value: 0.0
Suggested values: 0.0, 5.0, 10.0, 20.0, 50.0, 100.0
Restriction: PrincipalPointVar >= 0.0 && PrincipalPointVar <= 100.0
Internal camera parameters.
* Assume that GrayImage is one image in gray values with a
* resolution of 640 x 480 and a suitable number of contours. Then
* the following example performs the calibration using these
* contours and corrects the image with the estimated distortion
* parameters.
edges_sub_pix (GrayImage, Edges, 'canny', 1.0, 20, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 8, 4)
radial_distortion_self_calibration (ContoursSplit, SelectedContours, \
640, 480, 0.08, 42, 'division', \
'variable', 0, CameraParam)
get_domain (GrayImage, Domain)
change_radial_distortion_cam_par ('fullsize', CameraParam, 0, CamParamOut)
change_radial_distortion_image (GrayImage, Domain, ImageRectified, \
CameraParam, CamParamOut)
If the parameters are valid, the operator
radial_distortion_self_calibration radial_distortion_self_calibration RadialDistortionSelfCalibration radial_distortion_self_calibration RadialDistortionSelfCalibration RadialDistortionSelfCalibration returns the value 2 (H_MSG_TRUE).
If necessary an exception is raised.
edges_sub_pix edges_sub_pix EdgesSubPix edges_sub_pix EdgesSubPix EdgesSubPix ,
segment_contours_xld segment_contours_xld SegmentContoursXld segment_contours_xld SegmentContoursXld SegmentContoursXld
change_radial_distortion_cam_par change_radial_distortion_cam_par ChangeRadialDistortionCamPar change_radial_distortion_cam_par ChangeRadialDistortionCamPar ChangeRadialDistortionCamPar ,
change_radial_distortion_image change_radial_distortion_image ChangeRadialDistortionImage change_radial_distortion_image ChangeRadialDistortionImage ChangeRadialDistortionImage
camera_calibration camera_calibration CameraCalibration camera_calibration CameraCalibration CameraCalibration
T. Thormälen, H. Broszio: “Automatic line-based estimation of
radial lens distortion”; in: Integrated Computer-Aided
Engineering; vol. 12; pp. 177-190; 2005.
Calibration