Halcon標(biāo)定完成后的二維測(cè)量
1.gen_measure_rectangle2( : : Row, Column, Phi, Length1, Length2, Width, Height,Interpolation : MeasureHandle)
產(chǎn)生測(cè)量矩形句柄,控制輸入為測(cè)量矩形范圍的坐標(biāo)中心,矩形長(zhǎng)軸和水平方向夾角范圍的弧度,矩形邊長(zhǎng)的一半,測(cè)量圖片的寬和高度,輸出為測(cè)量句柄。
?
2.measure_pairs(Image : : MeasureHandle, Sigma, Threshold, Transition, Select :RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond,AmplitudeSecond, IntraDistance, InterDistance)
?
抽取和矩形主軸垂直的直線,返回第一類(lèi)和第二類(lèi)邊緣點(diǎn)的行列坐標(biāo)值,邊緣分類(lèi)由Transition的灰度差分決定。控制輸出還有,一個(gè)邊緣對(duì)之間的距離;以及一類(lèi)邊緣對(duì)相繼邊緣之間的距離。
?
3.image_points_to_world_plane( : : CameraParam, WorldPose, Rows, Cols, Scale : X, Y)
?
把像素坐標(biāo)轉(zhuǎn)化到世界坐標(biāo)系中的Z=0平面中的X,Y坐標(biāo)??刂戚斎霝椋鄼C(jī)內(nèi)參數(shù),標(biāo)定的世界坐標(biāo)位姿,測(cè)量單位,像素坐標(biāo),輸出為Z=0平面的X,Y坐標(biāo)。
?
4.distance_pp( : : Row1, Column1, Row2, Column2 : Distance)
?
利用兩點(diǎn)距離公式計(jì)算兩點(diǎn)之間的距離。
?
注意用法:distance_pp (X1[0:4], Y1[0:4], X1[1:5], Y1[1:5], Distance)
?
5.tuple_mean( : : Tuple : Mean) 返回?cái)?shù)組的平均值。
?
6.tuple_deviation( : : Tuple : Deviation) 返回?cái)?shù)組中所有元素的標(biāo)準(zhǔn)差。
?
對(duì)應(yīng)的HALCON單相機(jī)標(biāo)定后的測(cè)量程序段如下:
?
? ?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)
?