ClassesClassesClassesClasses | | | | Operators

camera_calibrationT_camera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration (Operator)

Name

camera_calibrationT_camera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration — Determine all camera parameters by a simultaneous minimization process.

Signature

camera_calibration( : : NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, EstimateParams : CameraParam, NFinalPose, Errors)

Herror T_camera_calibration(const Htuple NX, const Htuple NY, const Htuple NZ, const Htuple NRow, const Htuple NCol, const Htuple StartCamParam, const Htuple NStartPose, const Htuple EstimateParams, Htuple* CameraParam, Htuple* NFinalPose, Htuple* Errors)

Herror camera_calibration(const HTuple& NX, const HTuple& NY, const HTuple& NZ, const HTuple& NRow, const HTuple& NCol, const HTuple& StartCamParam, const HTuple& NStartPose, const HTuple& EstimateParams, HTuple* CameraParam, HTuple* NFinalPose, HTuple* Errors)

void CameraCalibration(const HTuple& NX, const HTuple& NY, const HTuple& NZ, const HTuple& NRow, const HTuple& NCol, const HTuple& StartCamParam, const HTuple& NStartPose, const HTuple& EstimateParams, HTuple* CameraParam, HTuple* NFinalPose, HTuple* Errors)

static HTuple HPose::CameraCalibration(const HTuple& NX, const HTuple& NY, const HTuple& NZ, const HTuple& NRow, const HTuple& NCol, const HTuple& StartCamParam, const HPoseArray& NStartPose, const HTuple& EstimateParams, HPoseArray* NFinalPose, HTuple* Errors)

HTuple HPose::CameraCalibration(const HTuple& NX, const HTuple& NY, const HTuple& NZ, const HTuple& NRow, const HTuple& NCol, const HTuple& StartCamParam, const HTuple& EstimateParams, HPose* NFinalPose, double* Errors) const

void HOperatorSetX.CameraCalibration(
[in] VARIANT NX, [in] VARIANT NY, [in] VARIANT NZ, [in] VARIANT NRow, [in] VARIANT NCol, [in] VARIANT StartCamParam, [in] VARIANT NStartPose, [in] VARIANT EstimateParams, [out] VARIANT* CameraParam, [out] VARIANT* NFinalPose, [out] VARIANT* Errors)

VARIANT HPoseX.CameraCalibration(
[in] VARIANT NX, [in] VARIANT NY, [in] VARIANT NZ, [in] VARIANT NRow, [in] VARIANT NCol, [in] VARIANT StartCamParam, [in] VARIANT NStartPose, [in] VARIANT EstimateParams, [out] VARIANT* NFinalPose, [out] VARIANT* Errors)

static void HOperatorSet.CameraCalibration(HTuple NX, HTuple NY, HTuple NZ, HTuple NRow, HTuple NCol, HTuple startCamParam, HTuple NStartPose, HTuple estimateParams, out HTuple cameraParam, out HTuple NFinalPose, out HTuple errors)

static HTuple HPose.CameraCalibration(HTuple NX, HTuple NY, HTuple NZ, HTuple NRow, HTuple NCol, HTuple startCamParam, HPose[] NStartPose, HTuple estimateParams, out HPose[] NFinalPose, out HTuple errors)

HTuple HPose.CameraCalibration(HTuple NX, HTuple NY, HTuple NZ, HTuple NRow, HTuple NCol, HTuple startCamParam, HTuple estimateParams, out HPose NFinalPose, out double errors)

Description

camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration performs the calibration of a single camera. For this, known 3D model points (with coordinates NXNXNXNXNXNX, NYNYNYNYNYNY, NZNZNZNZNZNZ) are projected into the image and the sum of the squared distances between the projected 3D-coordinates and their corresponding image point coordinates (NRowNRowNRowNRowNRowNRow, NColNColNColNColNColNCol) is minimized.

As initial values for the minimization process the internal (StartCamParamStartCamParamStartCamParamStartCamParamStartCamParamstartCamParam) and external (NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose) camera parameters are used. Individual camera parameters can be explicitely included or excluded from the minimization with EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams. For a detailed description of the available camera models, the different sets of internal camera parameters, and general requirements for the setup, see calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras.

For a successful calibration, at least one calibration object with accurately known metric properties is needed, e.g., a HALCON calibration plate. Before calling calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras, take a series of images of the calibration object in different orientations and make sure that the whole field of view or measurement volume is covered. The success of the calibration highly depends on the quality of the calibration object and the images. So you might want to exercise special diligence during the acquisiton of the calibration images. See the section “How to take a set of suitable images?” in calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras for further details.

After a successful calibration, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration returns the optimized internal (CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam) and external (NFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPose) camera parameters of the camera. Additionally, the root mean square error (RMSE) of the back projection of the optimization is returned in ErrorsErrorsErrorsErrorsErrorserrors (in pixels). This error gives a general indication whether the optimization was successful.

Preparation of the calibration process

How to extract the calibration marks in the images?

If a HALCON calibration plate is used, you can use the operator find_calib_objectfind_calib_objectFindCalibObjectfind_calib_objectFindCalibObjectFindCalibObject to determine the coordinates of the calibration marks in each image and to compute a rough estimate for the external camera parameters. Using HALCON calibration plates with rectangularly arranged marks (see gen_caltabgen_caltabGenCaltabgen_caltabGenCaltabGenCaltab), a combination of the two operators find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab and find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose will have the same effect. In both cases, the hereby obtained values can directly be used as initial values for the external camera parameters (NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose).

Obviously, images in which the segmentation of the calibration plate (find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab) has failed or the calibration marks have not been determined successfully by find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose or find_calib_objectfind_calib_objectFindCalibObjectfind_calib_objectFindCalibObjectFindCalibObject should not be used.

How do you get the required initial values for the calibration?

If you use a HALCON calibration plate, the input parameters NXNXNXNXNXNX, NYNYNYNYNYNY, and NZNZNZNZNZNZ are stored in the description file of the calibration plate. You can easily access them by calling the operator caltab_pointscaltab_pointsCaltabPointscaltab_pointsCaltabPointsCaltabPoints. Initial values for the internal camera parameters (StartCamParamStartCamParamStartCamParamStartCamParamStartCamParamstartCamParam) can be obtained from the specifications of the used camera. Further information can be found in calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras. Initial values for the poses of the calibration plate and the coordinates of the calibration marks NRowNRowNRowNRowNRowNRow and NColNColNColNColNColNCol can be calculated using the operator find_calib_objectfind_calib_objectFindCalibObjectfind_calib_objectFindCalibObjectFindCalibObject. The tuple NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose is set by the concatenation of all these poses.

Which camera parameters are estimated?

The input parameter EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams is used to select which camera parameters to estimate. Usually, this parameter is set to 'all'"all""all""all""all""all", i.e., all 6 external camera parameters (translation and rotation) and all internal camera parameters are determined. If the internal camera parameters already have been determined (e.g., by a previous call to camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration), it is often desired to only determine the pose of the world coordinate system in camera coordinates (i.e., the external camera parameters). In this case, EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams can be set to 'pose'"pose""pose""pose""pose""pose". This has the same effect as EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams = ['alpha','beta','gamma','transx','transy','transz']["alpha","beta","gamma","transx","transy","transz"]["alpha","beta","gamma","transx","transy","transz"]["alpha","beta","gamma","transx","transy","transz"]["alpha","beta","gamma","transx","transy","transz"]["alpha","beta","gamma","transx","transy","transz"]. Otherwise, EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams contains a tuple of strings that indicates the combination of parameters to estimate. In addition, parameters can be excluded from estimation by using the prefix ~. For example, the values ['pose','~transx']["pose","~transx"]["pose","~transx"]["pose","~transx"]["pose","~transx"]["pose","~transx"] have the same effect as ['alpha','beta','gamma','transy','transz']["alpha","beta","gamma","transy","transz"]["alpha","beta","gamma","transy","transz"]["alpha","beta","gamma","transy","transz"]["alpha","beta","gamma","transy","transz"]["alpha","beta","gamma","transy","transz"]. As a different example, ['all','~focus']["all","~focus"]["all","~focus"]["all","~focus"]["all","~focus"]["all","~focus"] determines all internal and external parameters except the focus. The prefix ~ can be used with all parameter values except 'all'.

Which limitations exist for the determination of the camera parameters?

For additional informations about general limitations when determining camera parameters, please see the section “Limitations” in the reference entry of calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras.

What is the order within the individual parameters?

The length of the tuple NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose depends on the number of calibration images, e.g., using 15 images leads to a length of the tuple NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose equal to (15 times the 7 external camera parameters). The first 7 values correspond to the pose of the calibration plate in the first image, the next 7 values to the pose in the second image, etc.

This fixed number of calibration images must be considered within the tuples with the coordinates of the 3D model marks and the extracted 2D marks. If 15 images are used, the length of the tuples NRowNRowNRowNRowNRowNRow and NColNColNColNColNColNCol is 15 times the length of the tuples with the coordinates of the 3D model marks (NXNXNXNXNXNX, NYNYNYNYNYNY, and NZNZNZNZNZNZ). If every image consists 49 marks, the length of the tuples NRowNRowNRowNRowNRowNRow and NColNColNColNColNColNCol is , while the length of the tuples NXNXNXNXNXNX, NYNYNYNYNYNY, and NZNZNZNZNZNZ is 49. The order of the values in NRowNRowNRowNRowNRowNRow and NColNColNColNColNColNCol is “image after image”, i.e., using 49 marks the first 3D model point corresponds to the 1st, 50th, 99th, 148th, 197th, 246th, etc. extracted 2D mark.

What is the meaning of the output parameters?

If the camera calibration process has finished successfully, the output parameters CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam and NFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPose contain the adjusted values for the internal and external camera parameters. The length of the tuple NFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPose corresponds to the length of the tuple NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose.

The representation types of NFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPose correspond to the representation type of the first tuple of NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose (see create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose). You can convert the representation type by convert_pose_typeconvert_pose_typeConvertPoseTypeconvert_pose_typeConvertPoseTypeConvertPoseType.

As an additional parameter, the root mean square error (RMSE) (ErrorsErrorsErrorsErrorsErrorserrors) of the back projection of the optimization is returned. This parameter reflects the accuracy of the calibration. The error value (root mean square error of the position) is measured in pixels. If only a single camera is calibrated, an Error in the order of 0.1 pixel (the typical detection error by extraction of the coordinates of the projected calibration markers) is an indication that the optimization fits the observation data well. If ErrorsErrorsErrorsErrorsErrorserrors strongly differs from 0.1 pixels, the calibration did not perform well. Reasons for this might be, e.g., a poor image quality, an insufficient number of calibration images, or an inaccurate calibration plate.

Do I have to use a planar calibration object?

No. The operator camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration is designed in a way that the input tuples NXNXNXNXNXNX, NYNYNYNYNYNY, NZNZNZNZNZNZ, NRowNRowNRowNRowNRowNRow, and NColNColNColNColNColNCol can contain any 3D/2D correspondences. The order of the single parameters is explained in the paragraph “What is the order within the individual parameters?”.

Thus, it makes no difference how the required 3D model marks and the corresponding 2D marks are determined. On the one hand, it is possible to use a 3D calibration object, on the other hand, you also can use any characteristic points (e.g. natural landmarks) with known position in the world. By setting EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams to 'pose'"pose""pose""pose""pose""pose", it is thus possible to compute the pose of an object in camera coordinates! For this, at least three 3D/2D-correspondences are necessary as input. NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose can, e.g., be generated directly as shown in the program example for create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose.

Attention

The minimization process of the calibration depends on the initial values of the internal (StartCamParamStartCamParamStartCamParamStartCamParamStartCamParamstartCamParam) and external (NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose) camera parameters. The computed average errors ErrorsErrorsErrorsErrorsErrorserrors give an impression of the accuracy of the calibration. The errors (deviations in x- and y-coordinates) are measured in pixels.

For line scan cameras, it is possible to set the start value for the internal camera parameter Sy to the value 0.0. In this case, it is not possible to determine the position of the principal point in y-direction. Therefore, EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams must contain the term '~cy'"~cy""~cy""~cy""~cy""~cy". The effective distance of the principle point from the sensor line is then always . Further information can be found in the section “Limitations” of calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras.

Parallelization

Parameters

NXNXNXNXNXNX (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all x coordinates of the calibration marks (in meters).

NYNYNYNYNYNY (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all y coordinates of the calibration marks (in meters).

Number of elements: NY == NX

NZNZNZNZNZNZ (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all z coordinates of the calibration marks (in meters).

Number of elements: NZ == NX

NRowNRowNRowNRowNRowNRow (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all row coordinates of the extracted calibration marks (in pixels).

NColNColNColNColNColNCol (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all column coordinates of the extracted calibration marks (in pixels).

Number of elements: NCol == NRow

StartCamParamStartCamParamStartCamParamStartCamParamStartCamParamstartCamParam (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Initial values for the internal camera parameters.

Number of elements: StartCamParam == 8 || StartCamParam == 10 || StartCamParam == 11 || StartCamParam == 12 || StartCamParam == 14

NStartPoseNStartPoseNStartPoseNStartPoseNStartPoseNStartPose (input_control)  pose(-array) HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all initial values for the external camera parameters.

Number of elements: NStartPose == 7 * NRow / NX

EstimateParamsEstimateParamsEstimateParamsEstimateParamsEstimateParamsestimateParams (input_control)  string-array HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Camera parameters to be estimated.

Default value: 'all' "all" "all" "all" "all" "all"

List of values: 'all'"all""all""all""all""all", 'alpha'"alpha""alpha""alpha""alpha""alpha", 'beta'"beta""beta""beta""beta""beta", 'camera'"camera""camera""camera""camera""camera", 'cx'"cx""cx""cx""cx""cx", 'cy'"cy""cy""cy""cy""cy", 'focus'"focus""focus""focus""focus""focus", 'gamma'"gamma""gamma""gamma""gamma""gamma", 'k1'"k1""k1""k1""k1""k1", 'k2'"k2""k2""k2""k2""k2", 'k3'"k3""k3""k3""k3""k3", 'kappa'"kappa""kappa""kappa""kappa""kappa", 'poly'"poly""poly""poly""poly""poly", 'poly_tan_2'"poly_tan_2""poly_tan_2""poly_tan_2""poly_tan_2""poly_tan_2", 'pose'"pose""pose""pose""pose""pose", 'sx'"sx""sx""sx""sx""sx", 'sy'"sy""sy""sy""sy""sy", 'tilt'"tilt""tilt""tilt""tilt""tilt", 'transx'"transx""transx""transx""transx""transx", 'transy'"transy""transy""transy""transy""transy", 'transz'"transz""transz""transz""transz""transz", 'vx'"vx""vx""vx""vx""vx", 'vy'"vy""vy""vy""vy""vy", 'vz'"vz""vz""vz""vz""vz"

CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam (output_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Internal camera parameters.

Number of elements: CameraParam == 8 || CameraParam == 10 || CameraParam == 11 || CameraParam == 12 || CameraParam == 14

NFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPoseNFinalPose (output_control)  pose(-array) HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Ordered tuple with all external camera parameters.

Number of elements: NFinalPose == 7 * NRow / NX

ErrorsErrorsErrorsErrorsErrorserrors (output_control)  real(-array) HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Average error distance in pixels.

Example (HDevelop)

*  Read calibration images
read_image(Image1, 'calib/calib-01')
read_image(Image2, 'calib/calib-02')
read_image(Image3, 'calib/calib-03')
*  Find calibration pattern
find_caltab(Image1, CalPlate1, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image2, CalPlate2, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image3, CalPlate3, 'caltab_big.descr', 3, 112, 5)
*  Find calibration marks and start poses
find_marks_and_pose(Image1, CalPlate1, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, CalPlate2, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, CalPlate3, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  Read 3D positions of calibration marks
caltab_points('caltab_big.descr', NX, NY, NZ)
*  Camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], \
                   [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  Write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Example (HDevelop)

*  Read calibration images
read_image(Image1, 'calib/calib-01')
read_image(Image2, 'calib/calib-02')
read_image(Image3, 'calib/calib-03')
*  Find calibration pattern
find_caltab(Image1, CalPlate1, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image2, CalPlate2, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image3, CalPlate3, 'caltab_big.descr', 3, 112, 5)
*  Find calibration marks and start poses
find_marks_and_pose(Image1, CalPlate1, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, CalPlate2, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, CalPlate3, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  Read 3D positions of calibration marks
caltab_points('caltab_big.descr', NX, NY, NZ)
*  Camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], \
                   [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  Write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Example (HDevelop)

*  Read calibration images
read_image(Image1, 'calib/calib-01')
read_image(Image2, 'calib/calib-02')
read_image(Image3, 'calib/calib-03')
*  Find calibration pattern
find_caltab(Image1, CalPlate1, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image2, CalPlate2, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image3, CalPlate3, 'caltab_big.descr', 3, 112, 5)
*  Find calibration marks and start poses
find_marks_and_pose(Image1, CalPlate1, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, CalPlate2, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, CalPlate3, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  Read 3D positions of calibration marks
caltab_points('caltab_big.descr', NX, NY, NZ)
*  Camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], \
                   [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  Write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Example (C++ (HALCON 5.0-10.0))

HTuple StartCamPar, NX, NY, NZ;
HTuple RCoord1, CCoord1, StartPose1;
HTuple RCoord2, CCoord2, StartPose2;
HTuple RCoord3, CCoord3, StartPose3;
HTuple StartPoses, RCoords, CCoords;
HTuple CameraParam, NFinalPose, Errors;
// read calibration images
HImage Image1("calib/calib-01");
HImage Image2("calib/calib-02");
HImage Image3("calib/calib-03");
// find calibration pattern
HRegion CalPlate1 = Image1.FindCaltab("caltab_big.descr", 3, 112, 5);
HRegion CalPlate2 = Image2.FindCaltab("caltab_big.descr", 3, 112, 5);
HRegion CalPlate3 = Image3.FindCaltab("caltab_big.descr", 3, 112, 5);
// find calibration marks and start poses
StartCamPar[7] = 576;          // ImageHeight
StartCamPar[6] = 768;          // ImageWidth
StartCamPar[5] = 288;          // Cy
StartCamPar[4] = 384;          // Cx
StartCamPar[3] = 0.000011;     // Sy
StartCamPar[2] = 0.000011;     // Sx
StartCamPar[1] = 0.0;          // Kappa
StartCamPar[0] = 0.008;        // Focus
RCoord1 = Image1.FindMarksAndPose(CalPlate1, "caltab_big.descr", StartCamPar,
                                  128, 10, &CCoord1, &StartPose1);
RCoord2 = Image2.FindMarksAndPose(CalPlate2, "caltab_big.descr", StartCamPar,
                                  128, 10, &CCoord2, &StartPose2);
RCoord3 = Image3.FindMarksAndPose(CalPlate3, "caltab_big.descr", StartCamPar,
                                  128, 10, &CCoord3, &StartPose3);
// read 3D positions of calibration marks
caltab_points("caltab_big.descr", &NX, &NY, &NZ);
// camera calibration
StartPoses = (StartPose1.Append(StartPose2)).Append(StartPose3);
RCoords = (RCoord1.Append(RCoord2)).Append(RCoord3);
CCoords = (CCoord1.Append(CCoord2)).Append(CCoord3);
camera_calibration(NX, NY, NZ, RCoords, CCoords, StartCamPar, StartPoses,
                   "all", &CameraParam, &NFinalPose, &Errors);
// write internal camera parameters to file
write_cam_par(CameraParam, "campar.dat");

Example (HDevelop)

*  Read calibration images
read_image(Image1, 'calib/calib-01')
read_image(Image2, 'calib/calib-02')
read_image(Image3, 'calib/calib-03')
*  Find calibration pattern
find_caltab(Image1, CalPlate1, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image2, CalPlate2, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image3, CalPlate3, 'caltab_big.descr', 3, 112, 5)
*  Find calibration marks and start poses
find_marks_and_pose(Image1, CalPlate1, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, CalPlate2, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, CalPlate3, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  Read 3D positions of calibration marks
caltab_points('caltab_big.descr', NX, NY, NZ)
*  Camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], \
                   [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  Write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Example (HDevelop)

*  Read calibration images
read_image(Image1, 'calib/calib-01')
read_image(Image2, 'calib/calib-02')
read_image(Image3, 'calib/calib-03')
*  Find calibration pattern
find_caltab(Image1, CalPlate1, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image2, CalPlate2, 'caltab_big.descr', 3, 112, 5)
find_caltab(Image3, CalPlate3, 'caltab_big.descr', 3, 112, 5)
*  Find calibration marks and start poses
find_marks_and_pose(Image1, CalPlate1, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, CalPlate2, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, CalPlate3, 'caltab_big.descr', \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  Read 3D positions of calibration marks
caltab_points('caltab_big.descr', NX, NY, NZ)
*  Camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], \
                   [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  Write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Result

camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration returns 2 (H_MSG_TRUE) if all parameter values are correct and the desired camera parameters have been determined by the minimization algorithm. If necessary, an exception is raised.

Possible Predecessors

find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose, caltab_pointscaltab_pointsCaltabPointscaltab_pointsCaltabPointsCaltabPoints, read_cam_parread_cam_parReadCamParread_cam_parReadCamParReadCamPar

Possible Successors

write_posewrite_poseWritePosewrite_poseWritePoseWritePose, pose_to_hom_mat3dpose_to_hom_mat3dPoseToHomMat3dpose_to_hom_mat3dPoseToHomMat3dPoseToHomMat3d, disp_caltabdisp_caltabDispCaltabdisp_caltabDispCaltabDispCaltab, sim_caltabsim_caltabSimCaltabsim_caltabSimCaltabSimCaltab

Alternatives

calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras

See also

find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab, find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose, disp_caltabdisp_caltabDispCaltabdisp_caltabDispCaltabDispCaltab, sim_caltabsim_caltabSimCaltabsim_caltabSimCaltabSimCaltab, write_cam_parwrite_cam_parWriteCamParwrite_cam_parWriteCamParWriteCamPar, read_cam_parread_cam_parReadCamParread_cam_parReadCamParReadCamPar, create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, convert_pose_typeconvert_pose_typeConvertPoseTypeconvert_pose_typeConvertPoseTypeConvertPoseType, write_posewrite_poseWritePosewrite_poseWritePoseWritePose, read_poseread_poseReadPoseread_poseReadPoseReadPose, pose_to_hom_mat3dpose_to_hom_mat3dPoseToHomMat3dpose_to_hom_mat3dPoseToHomMat3dPoseToHomMat3d, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose, caltab_pointscaltab_pointsCaltabPointscaltab_pointsCaltabPointsCaltabPoints, gen_caltabgen_caltabGenCaltabgen_caltabGenCaltabGenCaltab, calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras

Module

Calibration


ClassesClassesClassesClasses | | | | Operators