QQ登录

只需一步,快速开始

1.7 halcon 上位机测量内六角扳手间距宽度

[ 复制链接 ]
这个帖子介绍一维测量一另一个实例,
使用measure_pairs 函数,快速 方便简单地实现内六角扳手的间距与宽度试算。

1.7 halcon 上位机测量内六角扳手间距宽度

1.7 halcon 上位机测量内六角扳手间距宽度

*从磁盘读取图片用于后续处理
read_image (Image, 'bin_switch/bin_switch_1')
*获取 图片长宽
get_image_size (Image, Width, Height)
dev_close_window ()
*打开 窗口,窗口长宽比与图片保持一致
dev_open_window_fit_image (Image, 0, 0, 640, 640, WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_display (Image)
*
* Define the rectangular ROI within which the edges will be detected
* and create the measure.
Row := 385
Column := 385
Phi := rad(-60)
Length1 := 60
Length2 := 10
Interpolation := 'nearest_neighbor'
*生成一测量矩形区域,后续的测量在些范围内执行,MeasureHandle为矩形句柄,后面函数会用到。
gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)
*
* Determine all edge pairs that have a negative transition, i.e., edge pairs
* that enclose dark regions.
Sigma := 1.1
Threshold := 20
Transition := 'negative'
Select := 'all'
*在上面生成矩形区域内进行,进行边缘对数的进取与计算。
measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
*
* Visualize the results
dev_display (Image)
dev_set_draw ('margin')
dev_set_color ('black')
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
*本地函数,用于显示测得的边缘对尺寸信息,RowEdgeFirst, ColumnEdgeFirst,为边缘对和第一条边缘中心行列坐标
*RowEdgeSecond, ColumnEdgeSecond,为第二条边缘中心行列坐标,
*IntraDistance, 为边缘对宽度,
*InterDistance, 为相邻连续两边缘对间的距离
*Phi,测量矩形 旋转角度, Length2,测量矩形半高, WindowHandle为显示 信息的窗口句柄
p_disp_dimensions (RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond, IntraDistance, InterDistance, Phi, Length2, WindowHandle)
* 释放前面 创建的矩形句柄
close_measure (MeasureHandle)

回复

使用道具 举报

点击查看
快速回复 返回列表 客服中心 搜索