卡尺-线-例子
作者:互联网
*读图
read_image (Image, 'D:/Project/PC/vision_2020/视库/样图/线路.bmp')
get_image_size (Image, Width, Height)
rgb1_to_gray (Image, Image)
dev_get_window (WindowHandle)
*在我们要检的边界上画线
draw_line (WindowHandle, Row1, Column1, Row2, Column2)
shapeParam:= [Row1,Column1,Row2,Column2]
*创建句柄
create_metrology_model (MetrologyHandle)
set_metrology_model_image_size (MetrologyHandle, Width, Height)
*添加线模型
* add_metrology_object_generic (MetrologyHandle, 'line', shapeParam, 5, 5, 1, 30, [], [], Index)
add_metrology_object_line_measure (MetrologyHandle, Row1, Column1, Row2, Column2, 20, 5, 1, 30, [], [], Index)
* add_metrology_object_line_measure( : : MetrologyHandle, RowBegin, ColumnBegin, RowEnd, ColumnEnd,
* MeasureLength1, MeasureLength2, MeasureSigma, MeasureThreshold, GenParamName, GenParamValue : Index)
* measure_length1:卡尺高度/2。
* measure_length2:卡尺宽度/2。
* measure_distance:此参数的值指定两个测量区域的中心之间的所需距离,不知何意
* num_measures:此参数的值指定所需的度量区域数,不知何意
*设置参数,这里根据自己需求设置,这一坨用的都是同一个算子
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'all') 该参数指定使用暗/亮或亮/暗边缘。
* set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',50)
* set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 40) 该参数指定每个度量对象的成功拟合实例的最大数量,之后该拟合将停止。
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1) 该参数指定高斯平滑的sigma。
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',50)该参数指定最小边缘幅度。
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic') 该参数指定要使用的插值类型。
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all') 该参数指定边缘端点的选择。
* set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7) 分数
*另外一些
* distance_threshold:apply_metrology_model使用随机搜索算法(RANSAC)来拟合几何形状。
* max_num_iterations:RANSAC算法估算适合所需几何形状所需的迭代次数。
* rand_seed:该参数指定用于RANSAC算法的随机数生成器的种子,该种子用于选择in运算符apply_metrology_model中的边。
* instance_outside_measure_regions:该参数指定对测量结果的验证。
*应用测量
apply_metrology_model (Image, MetrologyHandle)
*显示卡尺的中心线,即划的那条线
get_metrology_object_model_contour (Contour1, MetrologyHandle, 0, 1.5)
*开始找边缘,顺便把边缘上卡尺找到的所有点坐标输出在ROW,Column里面(数组形式)
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
*Contours为卡尺, Row, Column为卡尺找到的结果值
*获取线的起点和终点坐标
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
*获取找到的轮廓线
get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 1.5)
*清除
clear_metrology_model (MetrologyHandle)
标签:MetrologyHandle,set,metrology,object,param,例子,measure,卡尺 来源: https://www.cnblogs.com/dingyd/p/12957352.html