在上一帖子里是通过代码实现,内六角扳手间隔的测量,
https://gkbc8.com/thread-13510-1-1.html
其实还可以直接使用测量助手实现,更多直观,更方便
同样,打开测量助手 窗口,
1.8 halcon 上位机使用测量助手测量内六角扳手间距宽度
从磁盘转入图像C:/Users/Public/Documents/MVTec/HALCON-17.12-Progress/examples/images/bin_switch/bin_switch_8.png
使用窗口工具栏 上的绘制直线,来确定在图上要测量的内六角扳手,
在边缘选项卡中来回调节参数,如最小边缘幅度,平滑等,边观察图片上边缘提取效果。
在结果选项卡中可以看到生成的计算结果。
在生成代码选项卡内,点击插入代码,可快速生成代码用于导出使用。
- * Measure 03: Code generated by Measure 03
- * Measure 03: Prepare measurement
- AmplitudeThreshold := 40
- RoiWidthLen2 := 5
- set_system ('int_zooming', 'true')
- * Measure 03: Coordinates for line Measure 03 [0]
- LineRowStart_Measure_03_0 := 288.857
- LineColumnStart_Measure_03_0 := 301.033
- LineRowEnd_Measure_03_0 := 265.497
- LineColumnEnd_Measure_03_0 := 271.512
- * Measure 03: Convert coordinates to rectangle2 type
- TmpCtrl_Row := 0.5*(LineRowStart_Measure_03_0+LineRowEnd_Measure_03_0)
- TmpCtrl_Column := 0.5*(LineColumnStart_Measure_03_0+LineColumnEnd_Measure_03_0)
- TmpCtrl_Dr := LineRowStart_Measure_03_0-LineRowEnd_Measure_03_0
- TmpCtrl_Dc := LineColumnEnd_Measure_03_0-LineColumnStart_Measure_03_0
- TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
- TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
- TmpCtrl_Len2 := RoiWidthLen2
- * Measure 03: Create measure for line Measure 03 [0]
- * Measure 03: Attention: This assumes all images have the same size!
- gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 640, 480, 'nearest_neighbor', MsrHandle_Measure_03_0)
- * Measure 03: Coordinates for line Measure 03 [1]
- LineRowStart_Measure_03_1 := 166.361
- LineColumnStart_Measure_03_1 := 114.251
- LineRowEnd_Measure_03_1 := 243.277
- LineColumnEnd_Measure_03_1 := 47.6961
- * Measure 03: Convert coordinates to rectangle2 type
- TmpCtrl_Row := 0.5*(LineRowStart_Measure_03_1+LineRowEnd_Measure_03_1)
- TmpCtrl_Column := 0.5*(LineColumnStart_Measure_03_1+LineColumnEnd_Measure_03_1)
- TmpCtrl_Dr := LineRowStart_Measure_03_1-LineRowEnd_Measure_03_1
- TmpCtrl_Dc := LineColumnEnd_Measure_03_1-LineColumnStart_Measure_03_1
- TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
- TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
- TmpCtrl_Len2 := RoiWidthLen2
- * Measure 03: Create measure for line Measure 03 [1]
- * Measure 03: Attention: This assumes all images have the same size!
- gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 640, 480, 'nearest_neighbor', MsrHandle_Measure_03_1)
- * Measure 03: ***************************************************************
- * Measure 03: * The code which follows is to be executed once / measurement *
- * Measure 03: ***************************************************************
- * Measure 03: Load image
- read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-17.12-Progress/examples/images/bin_switch/bin_switch_8.png')
- * Measure 03: Execute measurements
- measure_pos (Image, MsrHandle_Measure_03_0, 1, AmplitudeThreshold, 'negative', 'all', Row_Measure_03_0, Column_Measure_03_0, Amplitude_Measure_03_0, Distance_Measure_03_0)
- measure_pos (Image, MsrHandle_Measure_03_1, 1, AmplitudeThreshold, 'negative', 'all', Row_Measure_03_1, Column_Measure_03_1, Amplitude_Measure_03_1, Distance_Measure_03_1)
- * Measure 03: Do something with the results
- * Measure 03: Clear measure when done
- close_measure (MsrHandle_Measure_03_0)
- close_measure (MsrHandle_Measure_03_1)
复制代码
|