ClassesClassesClassesClasses | | | | Operators

find_marks_and_poseT_find_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose (Operator)

Name

find_marks_and_poseT_find_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose — Extract the 2D calibration marks from the image and calculate initial values for the external camera parameters.

Signature

find_marks_and_pose(Image, CalTabRegion : : CalTabDescrFile, StartCamParam, StartThresh, DeltaThresh, MinThresh, Alpha, MinContLength, MaxDiamMarks : RCoord, CCoord, StartPose)

Herror T_find_marks_and_pose(const Hobject Image, const Hobject CalTabRegion, const Htuple CalTabDescrFile, const Htuple StartCamParam, const Htuple StartThresh, const Htuple DeltaThresh, const Htuple MinThresh, const Htuple Alpha, const Htuple MinContLength, const Htuple MaxDiamMarks, Htuple* RCoord, Htuple* CCoord, Htuple* StartPose)

Herror find_marks_and_pose(Hobject Image, Hobject CalTabRegion, const HTuple& CalTabDescrFile, const HTuple& StartCamParam, const HTuple& StartThresh, const HTuple& DeltaThresh, const HTuple& MinThresh, const HTuple& Alpha, const HTuple& MinContLength, const HTuple& MaxDiamMarks, HTuple* RCoord, HTuple* CCoord, HTuple* StartPose)

HTuple HImage::FindMarksAndPose(const HRegion& CalTabRegion, const HTuple& CalTabDescrFile, const HTuple& StartCamParam, const HTuple& StartThresh, const HTuple& DeltaThresh, const HTuple& MinThresh, const HTuple& Alpha, const HTuple& MinContLength, const HTuple& MaxDiamMarks, HTuple* CCoord, HTuple* StartPose) const

void FindMarksAndPose(const HObject& Image, const HObject& CalTabRegion, const HTuple& CalTabDescrFile, const HTuple& StartCamParam, const HTuple& StartThresh, const HTuple& DeltaThresh, const HTuple& MinThresh, const HTuple& Alpha, const HTuple& MinContLength, const HTuple& MaxDiamMarks, HTuple* RCoord, HTuple* CCoord, HTuple* StartPose)

HTuple HImage::FindMarksAndPose(const HRegion& CalTabRegion, const HString& CalTabDescrFile, const HTuple& StartCamParam, Hlong StartThresh, Hlong DeltaThresh, Hlong MinThresh, double Alpha, double MinContLength, double MaxDiamMarks, HTuple* CCoord, HPose* StartPose) const

HTuple HImage::FindMarksAndPose(const HRegion& CalTabRegion, const char* CalTabDescrFile, const HTuple& StartCamParam, Hlong StartThresh, Hlong DeltaThresh, Hlong MinThresh, double Alpha, double MinContLength, double MaxDiamMarks, HTuple* CCoord, HPose* StartPose) const

void HOperatorSetX.FindMarksAndPose(
[in] IHUntypedObjectX* Image, [in] IHUntypedObjectX* CalTabRegion, [in] VARIANT CalTabDescrFile, [in] VARIANT StartCamParam, [in] VARIANT StartThresh, [in] VARIANT DeltaThresh, [in] VARIANT MinThresh, [in] VARIANT Alpha, [in] VARIANT MinContLength, [in] VARIANT MaxDiamMarks, [out] VARIANT* RCoord, [out] VARIANT* CCoord, [out] VARIANT* StartPose)

VARIANT HImageX.FindMarksAndPose(
[in] IHRegionX* CalTabRegion, [in] BSTR CalTabDescrFile, [in] VARIANT StartCamParam, [in] Hlong StartThresh, [in] Hlong DeltaThresh, [in] Hlong MinThresh, [in] double Alpha, [in] double MinContLength, [in] double MaxDiamMarks, [out] VARIANT* CCoord, [out] VARIANT* StartPose)

static void HOperatorSet.FindMarksAndPose(HObject image, HObject calTabRegion, HTuple calTabDescrFile, HTuple startCamParam, HTuple startThresh, HTuple deltaThresh, HTuple minThresh, HTuple alpha, HTuple minContLength, HTuple maxDiamMarks, out HTuple RCoord, out HTuple CCoord, out HTuple startPose)

HTuple HImage.FindMarksAndPose(HRegion calTabRegion, string calTabDescrFile, HTuple startCamParam, int startThresh, int deltaThresh, int minThresh, double alpha, double minContLength, double maxDiamMarks, out HTuple CCoord, out HPose startPose)

Description

find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose is used to determine the necessary input data for the subsequent camera calibration (see calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras or camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration): First, the 2D center points [RCoordRCoordRCoordRCoordRCoordRCoord,CCoordCCoordCCoordCCoordCCoordCCoord] of the calibration marks within the region CalTabRegionCalTabRegionCalTabRegionCalTabRegionCalTabRegioncalTabRegion of the input image ImageImageImageImageImageimage are extracted and ordered. Secondly, a rough estimate for the external camera parameters (StartPoseStartPoseStartPoseStartPoseStartPosestartPose) is computed, i.e., the 3D pose (= position and orientation) of the calibration plate relative to the camera coordinate system (see create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose for more information about 3D poses).

In the input image ImageImageImageImageImageimage an edge detector is applied (see edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage, mode 'lanser2') to the region CalTabRegionCalTabRegionCalTabRegionCalTabRegionCalTabRegioncalTabRegion, which can be found by applying the operator find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab. The filter parameter for this edge detection can be tuned via AlphaAlphaAlphaAlphaAlphaalpha. Use a smaller value for AlphaAlphaAlphaAlphaAlphaalpha to achieve a stronger smoothing effect. In the edge image closed contours are searched for: The number of closed contours must correspond to the number of calibration marks as described in the calibration plate description file CalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFilecalTabDescrFile and the contours have to be elliptically shaped. Contours shorter than MinContLengthMinContLengthMinContLengthMinContLengthMinContLengthminContLength are discarded, just as contours enclosing regions with a diameter larger than MaxDiamMarksMaxDiamMarksMaxDiamMarksMaxDiamMarksMaxDiamMarksmaxDiamMarks (e.g., the border of the calibration plate).

For the detection of contours a threshold operator is applied on the resulting amplitudes of the edge detector. All points with a high amplitude (i.e., borders of marks) are selected.

First, the threshold value is set to StartThreshStartThreshStartThreshStartThreshStartThreshstartThresh. If the search for the closed contours or the successive pose estimate fails, this threshold value is successively decreased by DeltaThreshDeltaThreshDeltaThreshDeltaThreshDeltaThreshdeltaThresh down to a minimum value of MinThreshMinThreshMinThreshMinThreshMinThreshminThresh.

Each of the found contours is refined with subpixel accuracy (see edges_sub_pixedges_sub_pixEdgesSubPixedges_sub_pixEdgesSubPixEdgesSubPix) and subsequently approximated by an ellipse. The center points of these ellipses represent a good approximation of the desired 2D image coordinates [RCoordRCoordRCoordRCoordRCoordRCoord,CCoordCCoordCCoordCCoordCCoordCCoord] of the calibration mark center points. The order of the values within these two tuples must correspond to the order of the 3D coordinates of the calibration marks in the calibration plate description file CalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFilecalTabDescrFile, since this fixes the correspondences between extracted image marks and known model marks (given by caltab_pointscaltab_pointsCaltabPointscaltab_pointsCaltabPointsCaltabPoints)! If a triangular orientation mark is defined in a corner of the plate by the plate description file (see gen_caltabgen_caltabGenCaltabgen_caltabGenCaltabGenCaltab), the mark will be detected and the point order is returned in row-major order beginning with the corner mark in the (barycentric) negative quadrant with respect to the defined coordinate system of the plate. Else, if no orientation mark is defined, the order of the center points is in row-major order beginning at the upper left corner mark in the image.

Based on the ellipse parameters for each calibration mark, a rough estimate for the external camera parameters is finally computed. For this purpose the fixed correspondences between extracted image marks and known model marks are used. The estimate StartPoseStartPoseStartPoseStartPoseStartPosestartPose describes the pose of the calibration plate in the camera coordinate system as required by the operator camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration.

Parallelization

Parameters

ImageImageImageImageImageimage (input_object)  singlechannelimage objectHImageHImageHImageHImageXHobject (byte / uint2)

Input image.

CalTabRegionCalTabRegionCalTabRegionCalTabRegionCalTabRegioncalTabRegion (input_object)  region objectHRegionHRegionHRegionHRegionXHobject

Region of the calibration plate.

CalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFileCalTabDescrFilecalTabDescrFile (input_control)  filename.read HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

File name of the calibration plate description.

Default value: 'caltab.descr' "caltab.descr" "caltab.descr" "caltab.descr" "caltab.descr" "caltab.descr"

List of values: 'caltab.descr'"caltab.descr""caltab.descr""caltab.descr""caltab.descr""caltab.descr", 'caltab_100mm.descr'"caltab_100mm.descr""caltab_100mm.descr""caltab_100mm.descr""caltab_100mm.descr""caltab_100mm.descr", 'caltab_10mm.descr'"caltab_10mm.descr""caltab_10mm.descr""caltab_10mm.descr""caltab_10mm.descr""caltab_10mm.descr", 'caltab_200mm.descr'"caltab_200mm.descr""caltab_200mm.descr""caltab_200mm.descr""caltab_200mm.descr""caltab_200mm.descr", 'caltab_30mm.descr'"caltab_30mm.descr""caltab_30mm.descr""caltab_30mm.descr""caltab_30mm.descr""caltab_30mm.descr"

File extension: .descr

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 == 11 || StartCamParam == 12

StartThreshStartThreshStartThreshStartThreshStartThreshstartThresh (input_control)  number HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Initial threshold value for contour detection.

Default value: 128

List of values: 80, 96, 112, 128, 144, 160

Restriction: StartThresh > 0

DeltaThreshDeltaThreshDeltaThreshDeltaThreshDeltaThreshdeltaThresh (input_control)  number HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Loop value for successive reduction of StartThreshStartThreshStartThreshStartThreshStartThreshstartThresh.

Default value: 10

List of values: 6, 8, 10, 12, 14, 16, 18, 20, 22

Restriction: DeltaThresh > 0

MinThreshMinThreshMinThreshMinThreshMinThreshminThresh (input_control)  number HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Minimum threshold for contour detection.

Default value: 18

List of values: 8, 10, 12, 14, 16, 18, 20, 22

Restriction: MinThresh > 0

AlphaAlphaAlphaAlphaAlphaalpha (input_control)  real HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Filter parameter for contour detection, see edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage.

Default value: 0.9

Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1

Typical range of values: 0.2 ≤ Alpha Alpha Alpha Alpha Alpha alpha ≤ 2.0

Restriction: Alpha > 0.0

MinContLengthMinContLengthMinContLengthMinContLengthMinContLengthminContLength (input_control)  real HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Minimum length of the contours of the marks.

Default value: 15.0

Suggested values: 10.0, 15.0, 20.0, 30.0, 40.0, 100.0

Restriction: MinContLength > 0.0

MaxDiamMarksMaxDiamMarksMaxDiamMarksMaxDiamMarksMaxDiamMarksmaxDiamMarks (input_control)  real HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Maximum expected diameter of the marks.

Default value: 100.0

Suggested values: 50.0, 100.0, 150.0, 200.0, 300.0

Restriction: MaxDiamMarks > 0.0

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

Tuple with row coordinates of the detected marks.

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

Tuple with column coordinates of the detected marks.

StartPoseStartPoseStartPoseStartPoseStartPosestartPose (output_control)  pose HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Estimation for the external camera parameters.

Number of elements: 7

Example (HDevelop)

*  read calibration image
read_image(Image, 'calib-01')
*  find calibration pattern
find_caltab(Image,Caltab1, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start pose
find_marks_and_pose(Image, Caltab, 'caltab.descr' , \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord, CCoord, StartPose)

Example (HDevelop)

*  read calibration image
read_image(Image, 'calib-01')
*  find calibration pattern
find_caltab(Image,Caltab1, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start pose
find_marks_and_pose(Image, Caltab, 'caltab.descr' , \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord, CCoord, StartPose)

Example (HDevelop)

*  read calibration image
read_image(Image, 'calib-01')
*  find calibration pattern
find_caltab(Image,Caltab1, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start pose
find_marks_and_pose(Image, Caltab, 'caltab.descr' , \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord, CCoord, StartPose)

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

HTuple StartCamPar, RCoord, CCoord, StartPose;
// read calibration image
HImage Image("calib-01");
// find calibration pattern
HRegion Caltab = Image.FindCaltab("caltab.descr", 3, 112, 5);
// read internal camera parameters from file
read_cam_par("campar.dat", &StartCamPar);
// find calibration marks and start pose
RCoord = Image.FindMarksAndPose(Caltab, "caltab.descr", StartCamPar,
                                128, 10, 18, 0.9, 15.0, 100.0,
                                &RCoord, &CCoord, &StartPose);

Example (HDevelop)

*  read calibration image
read_image(Image, 'calib-01')
*  find calibration pattern
find_caltab(Image,Caltab1, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start pose
find_marks_and_pose(Image, Caltab, 'caltab.descr' , \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord, CCoord, StartPose)

Example (HDevelop)

*  read calibration image
read_image(Image, 'calib-01')
*  find calibration pattern
find_caltab(Image,Caltab1, 'caltab.descr', 3, 112, 5)
*  find calibration marks and start pose
find_marks_and_pose(Image, Caltab, 'caltab.descr' , \
                    [0.008, 0.0, 0.000011, 0.000011, 384, 288, 768, 576], \
                    128, 10, 18, 0.9, 15.0, 100.0, RCoord, CCoord, StartPose)

Result

find_marks_and_posefind_marks_and_poseFindMarksAndPosefind_marks_and_poseFindMarksAndPoseFindMarksAndPose returns 2 (H_MSG_TRUE) if all parameter values are correct and an estimation for the external camera parameters has been determined successfully. If necessary, an exception is raised.

Possible Predecessors

find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab

Possible Successors

camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration

See also

find_caltabfind_caltabFindCaltabfind_caltabFindCaltabFindCaltab, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, disp_caltabdisp_caltabDispCaltabdisp_caltabDispCaltabDispCaltab, sim_caltabsim_caltabSimCaltabsim_caltabSimCaltabSimCaltab, read_cam_parread_cam_parReadCamParread_cam_parReadCamParReadCamPar, read_poseread_poseReadPoseread_poseReadPoseReadPose, create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, pose_to_hom_mat3dpose_to_hom_mat3dPoseToHomMat3dpose_to_hom_mat3dPoseToHomMat3dPoseToHomMat3d, caltab_pointscaltab_pointsCaltabPointscaltab_pointsCaltabPointsCaltabPoints, gen_caltabgen_caltabGenCaltabgen_caltabGenCaltabGenCaltab, edges_sub_pixedges_sub_pixEdgesSubPixedges_sub_pixEdgesSubPixEdgesSubPix, edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage

Module

Foundation


ClassesClassesClassesClasses | | | | Operators