QQ登录

只需一步,快速开始

1.8 halcon 上位机使用测量助手测量内六角扳手间距宽度

[ 复制链接 ]
在上一帖子里是通过代码实现,内六角扳手间隔的测量,
https://gkbc8.com/thread-13510-1-1.html
其实还可以直接使用测量助手实现,更多直观,更方便
同样,打开测量助手 窗口,

1.8 halcon 上位机使用测量助手测量内六角扳手间距宽度

1.8 halcon 上位机使用测量助手测量内六角扳手间距宽度

从磁盘转入图像C:/Users/Public/Documents/MVTec/HALCON-17.12-Progress/examples/images/bin_switch/bin_switch_8.png
使用窗口工具栏 上的绘制直线,来确定在图上要测量的内六角扳手,
在边缘选项卡中来回调节参数,如最小边缘幅度,平滑等,边观察图片上边缘提取效果。
在结果选项卡中可以看到生成的计算结果。
在生成代码选项卡内,点击插入代码,可快速生成代码用于导出使用。
  1. * Measure 03: Code generated by Measure 03
  2. * Measure 03: Prepare measurement
  3. AmplitudeThreshold := 40
  4. RoiWidthLen2 := 5
  5. set_system ('int_zooming', 'true')
  6. * Measure 03: Coordinates for line Measure 03 [0]
  7. LineRowStart_Measure_03_0 := 288.857
  8. LineColumnStart_Measure_03_0 := 301.033
  9. LineRowEnd_Measure_03_0 := 265.497
  10. LineColumnEnd_Measure_03_0 := 271.512
  11. * Measure 03: Convert coordinates to rectangle2 type
  12. TmpCtrl_Row := 0.5*(LineRowStart_Measure_03_0+LineRowEnd_Measure_03_0)
  13. TmpCtrl_Column := 0.5*(LineColumnStart_Measure_03_0+LineColumnEnd_Measure_03_0)
  14. TmpCtrl_Dr := LineRowStart_Measure_03_0-LineRowEnd_Measure_03_0
  15. TmpCtrl_Dc := LineColumnEnd_Measure_03_0-LineColumnStart_Measure_03_0
  16. TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
  17. TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
  18. TmpCtrl_Len2 := RoiWidthLen2
  19. * Measure 03: Create measure for line Measure 03 [0]
  20. * Measure 03: Attention: This assumes all images have the same size!
  21. gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 640, 480, 'nearest_neighbor', MsrHandle_Measure_03_0)
  22. * Measure 03: Coordinates for line Measure 03 [1]
  23. LineRowStart_Measure_03_1 := 166.361
  24. LineColumnStart_Measure_03_1 := 114.251
  25. LineRowEnd_Measure_03_1 := 243.277
  26. LineColumnEnd_Measure_03_1 := 47.6961
  27. * Measure 03: Convert coordinates to rectangle2 type
  28. TmpCtrl_Row := 0.5*(LineRowStart_Measure_03_1+LineRowEnd_Measure_03_1)
  29. TmpCtrl_Column := 0.5*(LineColumnStart_Measure_03_1+LineColumnEnd_Measure_03_1)
  30. TmpCtrl_Dr := LineRowStart_Measure_03_1-LineRowEnd_Measure_03_1
  31. TmpCtrl_Dc := LineColumnEnd_Measure_03_1-LineColumnStart_Measure_03_1
  32. TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
  33. TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
  34. TmpCtrl_Len2 := RoiWidthLen2
  35. * Measure 03: Create measure for line Measure 03 [1]
  36. * Measure 03: Attention: This assumes all images have the same size!
  37. gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 640, 480, 'nearest_neighbor', MsrHandle_Measure_03_1)
  38. * Measure 03: ***************************************************************
  39. * Measure 03: * The code which follows is to be executed once / measurement *
  40. * Measure 03: ***************************************************************
  41. * Measure 03: Load image
  42. read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-17.12-Progress/examples/images/bin_switch/bin_switch_8.png')
  43. * Measure 03: Execute measurements
  44. 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)
  45. 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)
  46. * Measure 03: Do something with the results
  47. * Measure 03: Clear measure when done
  48. close_measure (MsrHandle_Measure_03_0)
  49. close_measure (MsrHandle_Measure_03_1)
复制代码


回复

使用道具 举报

快速回复 返回列表 客服中心 搜索