ClassesClassesClassesClasses | | | | Operators

write_poseT_write_poseWritePosewrite_poseWritePoseWritePose (Operator)

Name

write_poseT_write_poseWritePosewrite_poseWritePoseWritePose — Write a 3D pose to a text file.

Signature

write_pose( : : Pose, PoseFile : )

Herror T_write_pose(const Htuple Pose, const Htuple PoseFile)

Herror write_pose(const HTuple& Pose, const HTuple& PoseFile)

void WritePose(const HTuple& Pose, const HTuple& PoseFile)

void HPose::WritePose(const HString& PoseFile) const

void HPose::WritePose(const char* PoseFile) const

void HOperatorSetX.WritePose(
[in] VARIANT Pose, [in] VARIANT PoseFile)

void HPoseX.WritePose(
[in] VARIANT Pose, [in] BSTR PoseFile)

static void HOperatorSet.WritePose(HTuple pose, HTuple poseFile)

void HPose.WritePose(string poseFile)

Description

write_posewrite_poseWritePosewrite_poseWritePoseWritePose is used to write a 3D pose PosePosePosePosePosepose into a text file with the name PoseFilePoseFilePoseFilePoseFilePoseFileposeFile. The default HALCON file extension for the 3D pose is 'dat'.

A pose describes a rigid 3D transformation, i.e., a transformation consisting of an arbitrary translation and rotation, with 6 parameters, three for the translation, three for the rotation. With a seventh parameter different pose types can be indicated (see create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose).

A file generated by write_posewrite_poseWritePosewrite_poseWritePoseWritePose looks like the following:

  # 3D POSE PARAMETERS: rotation and translation

  # Used representation type:
  f 0

  # Rotation angles [deg] or Rodriguez-vector:
  r -17.8134 1.83816 0.288092

  # Translational vector (x y z [m]):
  t 0.280164 0.150644 1.7554

Parallelization

Parameters

PosePosePosePosePosepose (input_control)  pose HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

3D pose.

Number of elements: 7

PoseFilePoseFilePoseFilePoseFilePoseFileposeFile (input_control)  filename.write HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

File name of the external camera parameters.

Default value: 'campose.dat' "campose.dat" "campose.dat" "campose.dat" "campose.dat" "campose.dat"

Suggested values: 'campose.dat'"campose.dat""campose.dat""campose.dat""campose.dat""campose.dat", 'campose_initial.dat'"campose_initial.dat""campose_initial.dat""campose_initial.dat""campose_initial.dat""campose_initial.dat", 'campose_final.dat'"campose_final.dat""campose_final.dat""campose_final.dat""campose_final.dat""campose_final.dat"

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 := [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576]
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 external camera parameters of first calibration image
write_pose(NFinalPose[0:6], 'campose.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 := [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576]
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 external camera parameters of first calibration image
write_pose(NFinalPose[0:6], 'campose.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 := [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576]
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 external camera parameters of first calibration image
write_pose(NFinalPose[0:6], 'campose.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, FinalPose, 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,
                   "all", &CameraParam, &NFinalPose, &Errors);
// write external camera parameters of first calibration image
FinalPose = NFinalPose(0,6);
write_pose(FinalPose, "campose.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 := [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576]
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 external camera parameters of first calibration image
write_pose(NFinalPose[0:6], 'campose.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 := [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576]
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 external camera parameters of first calibration image
write_pose(NFinalPose[0:6], 'campose.dat')

Result

write_posewrite_poseWritePosewrite_poseWritePoseWritePose 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_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose

See also

create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, disp_caltabdisp_caltabDispCaltabdisp_caltabDispCaltabDispCaltab, sim_caltabsim_caltabSimCaltabsim_caltabSimCaltabSimCaltab, read_poseread_poseReadPoseread_poseReadPoseReadPose, pose_to_hom_mat3dpose_to_hom_mat3dPoseToHomMat3dpose_to_hom_mat3dPoseToHomMat3dPoseToHomMat3d, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose

Module

Foundation


ClassesClassesClassesClasses | | | | Operators