read_image (Image, 'test.bmp') get_image_size (Image, Width, Height) dev_close_window () dev_open_window (0, 0, Width/2, Height/2, 'black', WindowHandle) dev_display (Image) dev_set_draw ('margin') draw_line (WindowHandle, Row1, Column1, Row2, Column2) draw_circle (WindowHandle, Row, Column, Radius) *【输入】 StartRow:=Row1 StartCol:=Column1 EndRow:=Row2 EndCol:=Column2 *卡尺宽度 RuleWidth:=40 *卡尺高度 RuleHeight:=1 *卡尺阈值 RuleThd:=5 *卡尺间隔 RuleSpace:=2 *搜索模式 RuleMode:='negative' *点选择 RuleSeleP:='all' *【输出】 LineRow0:=0 LineCol0:=0 LineRow1:=0 LineCol1:=0 PointRows:=[] PointCols:=[] MeasureLine (Image, Contours, Rectangle, StartRow, StartCol, EndRow, EndCol, RuleWidth, RuleHeight, RuleSpace, RuleThd, RuleSeleP, RuleMode, PointRows, PointCols, LineRow0, LineCol0, LineRow1, LineCol1) MeasureCircle (Image, Contours, Row, Column, Radius, RuleWidth, RuleHeight, RuleSpace, RuleThd, RuleSeleP, RuleMode, PointRows, PointCols, CircleRow, CircleCol, CircleRad) *显示 dev_display (Image) dev_display (Rectangle) dev_set_color ('spring green') dev_display (Contours) dev_set_color ('orange') gen_cross_contour_xld (Cross, PointRows, PointCols, 6, 0.785398) dev_set_color ('red') gen_circle_contour_xld (ContCircle, CircleRow, CircleCol, CircleRad, 0, 6.28318, 'positive', 1) gen_contour_polygon_xld (Contour, [LineRow0,LineRow1], [LineCol0,LineCol1])
main
*直线测量 create_metrology_model (MetrologyHandle) add_metrology_object_line_measure (MetrologyHandle, StartRow, StartCol, EndRow, EndCol, 100, 20, 1, 30, [], [], Index) *搜索宽度 set_metrology_object_param (MetrologyHandle, Index, 'measure_length1', RuleWidth) *有效搜索高度 set_metrology_object_param (MetrologyHandle, Index, 'measure_length2', RuleHeight) *搜索间隔 set_metrology_object_param (MetrologyHandle, Index, 'measure_distance', RuleSpace) *边缘阈值 set_metrology_object_param (MetrologyHandle, Index, 'measure_threshold', RuleThd) *边缘选择 set_metrology_object_param (MetrologyHandle, Index, 'measure_select',RuleSeleP) *过度方式 set_metrology_object_param (MetrologyHandle, Index, 'measure_transition', RuleMode) *对图像进行测量 apply_metrology_model (Image, MetrologyHandle) *测量点 get_metrology_object_measures (Contours, MetrologyHandle, Index, RuleMode, PointRows, PointCols) *测量直线 get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', ['row_begin', 'column_begin', 'row_end', 'column_end'], Parameter) *外围矩形 angle_lx (StartRow, StartCol, EndRow, EndCol, Angle) length1:=sqrt((StartCol-EndCol)*(StartCol-EndCol)+(StartRow-EndRow)*(StartRow-EndRow)) gen_rectangle2 (Rectangle, (StartRow+EndRow)/2, (StartCol+EndCol)/2, Angle, length1/2, RuleWidth) LineRow0:=Parameter[0] LineCol0:=Parameter[1] LineRow1:=Parameter[2] LineCol1:=Parameter[3] return ()
MeasureLine
*圆测量 create_metrology_model (MetrologyHandle) add_metrology_object_circle_measure (MetrologyHandle, Row, Column, Radius, 20, 5, 1, 30, [], [], Index) *搜索宽度 set_metrology_object_param (MetrologyHandle, Index, 'measure_length1', RuleWidth) *有效搜索高度 set_metrology_object_param (MetrologyHandle, Index, 'measure_length2', RuleHeight) *搜索间隔 set_metrology_object_param (MetrologyHandle, Index, 'measure_distance', RuleSpace) *边缘阈值 set_metrology_object_param (MetrologyHandle, Index, 'measure_threshold', RuleThd) *边缘选择 set_metrology_object_param (MetrologyHandle, Index, 'measure_select',RuleSeleP) *过度方式 set_metrology_object_param (MetrologyHandle, Index, 'measure_transition', RuleMode) *对图像进行测量 apply_metrology_model (Image, MetrologyHandle) *测量点 get_metrology_object_measures (Contours, MetrologyHandle, Index, RuleMode, PointRows, PointCols) *测量圆 get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', ['row', 'column', 'radius'], Parameter) CircleRow:=Parameter[0] CircleCol:=Parameter[1] CircleRad:=Parameter[2] return ()
MeasureCircle