# 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)

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

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

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

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

`   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的部分）。