HALCON Reference Manual 10.0.2
Table of Contents / Calibration / Camera Parameters ClassesClassesClasses | | | Operators

write_cam_parT_write_cam_parwrite_cam_parWriteCamParWriteCamPar (Operator)

Name

write_cam_parT_write_cam_parwrite_cam_parWriteCamParWriteCamPar — Write the internal camera parameters to a text file.

Signature

write_cam_par( : : CameraParam, CamParFile : )

Herror T_write_cam_par(const Htuple CameraParam, const Htuple CamParFile)

Herror write_cam_par(const HTuple& CameraParam, const HTuple& CamParFile)

void HOperatorSetX.WriteCamPar(
[in] VARIANT CameraParam, [in] VARIANT CamParFile)

void HMiscX.WriteCamPar(
[in] VARIANT CameraParam, [in] BSTR CamParFile)

static void HOperatorSet.WriteCamPar(HTuple cameraParam, HTuple camParFile)

static void HMisc.WriteCamPar(HTuple cameraParam, string camParFile)

Description

write_cam_parwrite_cam_parwrite_cam_parWriteCamParWriteCamPar is used to write the internal camera parameters CameraParamCameraParamCameraParamCameraParamcameraParam to a text file with name CamParFileCamParFileCamParFileCamParFilecamParFile. The default HALCON file extension for the camera parameters is 'dat'.

The internal camera parameters describe the projection process of the used combination of camera, lens, and frame grabber; they can be determined calibrating the camera using calibrate_camerascalibrate_camerascalibrate_camerasCalibrateCamerasCalibrateCameras or camera_calibrationcamera_calibrationcamera_calibrationCameraCalibrationCameraCalibration. The descriptions of these operators contain also detailed information about the available 3D camera models.

CameraParamCameraParamCameraParamCameraParamcameraParam is a tuple that contains the internal camera parameters in the following sequences:

For area scan cameras with the distortions modeled by the division model: [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]

For area scan cameras with the distortions modeled by the polynomial model: [Focus, Poly1, Poly2, Poly3, Poly4, Poly5, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]

For line scan cameras: [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight, Vx, Vy, Vz]

The format of the text file CamParFileCamParFileCamParFileCamParFilecamParFile is a (HALCON-independent) generic parameter description. It allows to group arbitrary sets of parameters hierarchically. The description of a single parameter within a parameter group consists of the following 3 lines:

   Name : Shortname : Actual value ;
    Type : Lower bound (optional) : Upper bound (optional) ;
    Description (optional) ;

Depending on the number of elements of CameraParamCameraParamCameraParamCameraParamcameraParam, the parameter groups Camera:Parameter or LinescanCamera:Parameter, respectively, are written into the text file CamParFileCamParFileCamParFileCamParFilecamParFile (see read_cam_parread_cam_parread_cam_parReadCamParReadCamPar for an example). The parameter group Camera:Parameter consists of the 8 internal camera parameters of the area scan camera for which the distortions are modeled by the division model or of the 12 internal camera parameters of the area scan camera for which the distortions are modeled by the polynomial model. The parameter group LinescanCamera:Parameter consists of the 11 internal camera parameters of the line scan camera.

Parallelization

Parameters

CameraParamCameraParamCameraParamCameraParamcameraParam (input_control)  number-array HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Internal camera parameters.

Number of elements: ((CameraParam == 8) || (CameraParam == 11)) || (CameraParam == 12)

CamParFileCamParFileCamParFileCamParFilecamParFile (input_control)  filename.write HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

File name of internal camera parameters.

Default value: 'campar.dat' "campar.dat" "campar.dat" "campar.dat" "campar.dat"

List of values: 'campar.dat'"campar.dat""campar.dat""campar.dat""campar.dat", 'campar.initial'"campar.initial""campar.initial""campar.initial""campar.initial", 'campar.final'"campar.final""campar.final""campar.final""campar.final"

File extension: .dat

Example (HDevelop)

*  read calibration images
read_image(Image1, 'calib-01')
read_image(Image2, 'calib-02')
read_image(Image3, 'calib-03')
*  find calibration pattern
find_caltab(Image1, Caltab1, 'caltab.descr', 3, 112, 5)
find_caltab(Image2, Caltab2, 'caltab.descr', 3, 112, 5)
find_caltab(Image3, Caltab3, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start poses
StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
find_marks_and_pose(Image1, Caltab1, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, Caltab2, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, Caltab3, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  read 3D positions of calibration marks
caltab_points('caltab.descr', NX, NY, NZ)
*  camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], StartCamPar, \
                   [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-01')
read_image(Image2, 'calib-02')
read_image(Image3, 'calib-03')
*  find calibration pattern
find_caltab(Image1, Caltab1, 'caltab.descr', 3, 112, 5)
find_caltab(Image2, Caltab2, 'caltab.descr', 3, 112, 5)
find_caltab(Image3, Caltab3, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start poses
StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
find_marks_and_pose(Image1, Caltab1, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, Caltab2, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, Caltab3, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  read 3D positions of calibration marks
caltab_points('caltab.descr', NX, NY, NZ)
*  camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], StartCamPar, \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Example (C++)

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-01");
HImage Image2("calib-02");
HImage Image3("calib-03");
// find calibration pattern
HRegion Caltab1 = Image1.FindCaltab("caltab.descr", 3, 112, 5);
HRegion Caltab2 = Image2.FindCaltab("caltab.descr", 3, 112, 5);
HRegion Caltab3 = Image3.FindCaltab("caltab.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(Caltab1, "caltab.descr",StartCamPar,
                                  128,10, &CCoord1, &StartPose1);
RCoord2 = Image2.FindMarksAndPose(Caltab2, "caltab.descr", StartCamPar,
                                  128,10, &CCoord2, &StartPose2);
RCoord3 = Image3.FindMarksAndPose(Caltab3, "caltab.descr", StartCamPar,
                                  128,10, &CCoord3, &StartPose3);
// read 3D positions of calibration marks
caltab_points("caltab.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,
                   11, &CameraParam, &NFinalPose, &Errors);
// write internal camera parameters to file
write_cam_par(CameraParam, "campar.dat");

Example (HDevelop)

*  read calibration images
read_image(Image1, 'calib-01')
read_image(Image2, 'calib-02')
read_image(Image3, 'calib-03')
*  find calibration pattern
find_caltab(Image1, Caltab1, 'caltab.descr', 3, 112, 5)
find_caltab(Image2, Caltab2, 'caltab.descr', 3, 112, 5)
find_caltab(Image3, Caltab3, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start poses
StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
find_marks_and_pose(Image1, Caltab1, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, Caltab2, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, Caltab3, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  read 3D positions of calibration marks
caltab_points('caltab.descr', NX, NY, NZ)
*  camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], StartCamPar, \
                   [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-01')
read_image(Image2, 'calib-02')
read_image(Image3, 'calib-03')
*  find calibration pattern
find_caltab(Image1, Caltab1, 'caltab.descr', 3, 112, 5)
find_caltab(Image2, Caltab2, 'caltab.descr', 3, 112, 5)
find_caltab(Image3, Caltab3, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start poses
StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
find_marks_and_pose(Image1, Caltab1, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord1, CCoord1, \
                    StartPose1)
find_marks_and_pose(Image2, Caltab2, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord2, CCoord2, \
                    StartPose2)
find_marks_and_pose(Image3, Caltab3, 'caltab.descr', StartCamPar, \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord3, CCoord3, \
                    StartPose3)
*  read 3D positions of calibration marks
caltab_points('caltab.descr', NX, NY, NZ)
*  camera calibration
camera_calibration(NX, NY, NZ, [RCoord1, RCoord2, RCoord3], \
                   [CCoord1, CCoord2, CCoord3], StartCamPar, \
                   [StartPose1, StartPose2, StartPose3], 'all', \
                   CameraParam, NFinalPose, Errors)
*  write internal camera parameters to file
write_cam_par(CameraParam, 'campar.dat')

Result

write_cam_parwrite_cam_parwrite_cam_parWriteCamParWriteCamPar returns 2 (H_MSG_TRUE) if all parameter values are correct and the file has been written successfully. If necessary an exception is raised.

Possible Predecessors

camera_calibrationcamera_calibrationcamera_calibrationCameraCalibrationCameraCalibration

See also

find_caltabfind_caltabfind_caltabFindCaltabFindCaltab, find_marks_and_posefind_marks_and_posefind_marks_and_poseFindMarksAndPoseFindMarksAndPose, camera_calibrationcamera_calibrationcamera_calibrationCameraCalibrationCameraCalibration, disp_caltabdisp_caltabdisp_caltabDispCaltabDispCaltab, sim_caltabsim_caltabsim_caltabSimCaltabSimCaltab, read_cam_parread_cam_parread_cam_parReadCamParReadCamPar, write_posewrite_posewrite_poseWritePoseWritePose, read_poseread_poseread_poseReadPoseReadPose, project_3d_pointproject_3d_pointproject_3d_pointProject3dPointProject3dPoint, get_line_of_sightget_line_of_sightget_line_of_sightGetLineOfSightGetLineOfSight

Module

Foundation


Table of Contents / Calibration / Camera Parameters ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH