halcon学习笔记——(7)HALCON标定后的二维测量

1.gen_measure_rectangle2( : : Row, Column, Phi, Length1, Length2, Width, Height,Interpolation : MeasureHandle)

产生测量矩形句柄,控制输入为测量矩形范围的坐标中心,矩形长轴和水平方向夹角范围的弧度,矩形边长的一半,测量图片的宽和高度,输出为测量句柄。

2.measure_pairs(Image : : MeasureHandle, Sigma, Threshold, Transition, Select :RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond,AmplitudeSecond, IntraDistance, InterDistance)

抽取和矩形主轴垂直的直线,返回第一类和第二类边缘点的行列坐标值,边缘分类由Transition的灰度差分决定。控制输出还有,一个边缘对之间的距离;以及一类边缘对相继边缘之间的距离。

3.image_points_to_world_plane( : : CameraParam, WorldPose, Rows, Cols, Scale : X, Y)

把像素坐标转化到世界坐标系中的Z=0平面中的X,Y坐标。控制输入为,相机内参数,标定的世界坐标位姿,测量单位,像素坐标,输出为Z=0平面的X,Y坐标。

4.distance_pp( : : Row1, Column1, Row2, Column2 : Distance)

利用两点距离公式计算两点之间的距离。

注意用法:distance_pp (X1[0:4], Y1[0:4], X1[1:5], Y1[1:5], Distance)

5.tuple_mean( : : Tuple : Mean) 返回数组的平均值。

6.tuple_deviation( : : Tuple : Deviation) 返回数组中所有元素的标准差。

对应的HALCON单相机标定后的测量程序段如下:

   1: calibrate_cameras (CalibDataID, Errors)
   2: get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)
   3: NumImage := 11
   4: get_calib_data (CalibDataID, 'calib_obj_pose', [0, NumImage], 'pose', Pose)
   5: * To take the thickness of the calibration plate into account, the z-value
   6: * of the origin given by the camera pose has to be translated by the
   7: * thickness of the calibration plate.
   8: * Deactivate the following line if you do not want to add the correction.
   9: set_origin_pose (Pose, 0, 0, 0.00075, Pose)
  10: * measure the distance between the pitch lines
  11: gen_measure_rectangle2 (195, 226, -0.526627271434, 174, 3, 652, 494, 'bilinear', MeasureHandle)
  12: measure_pairs (Image, MeasureHandle, 0.5, 5, 'all', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
  13: Row := (RowEdgeFirst+RowEdgeSecond)/2.0
  14: Col := (ColumnEdgeFirst+ColumnEdgeSecond)/2.0
  15: disp_cross (WindowHandle, Row, Col, 6, 0)
  16: image_points_to_world_plane (CamParam, Pose, Row, Col, 'mm', X1, Y1)
  17: distance_pp (X1[0:4], Y1[0:4], X1[1:5], Y1[1:5], Distance)
  18: tuple_mean (Distance, MeanDistance)
  19: tuple_deviation (Distance, DeviationDistance)
  20: disp_message (WindowHandle, 'Mean distance: '+MeanDistance$'.3f'+'mm +/- '+DeviationDistance$'.3f'+'mm', 'window', 30, 150, 'yellow', 'false')
  21: close_measure (MeasureHandle)
  22: clear_calib_data (CalibDataID)

(以上代码出自solution_guide/3d_vision/camera_calibration_multi_image.hdev的部分)。

你可能感兴趣的:(halcon学习笔记——(7)HALCON标定后的二维测量)