halcon视觉第二十三讲 Halcon测量助手使用


测量助手窗口


图像源

1.图像窗口

halcon窗口中已经有图片了就选这个

2.图像文件

选择一张图片

3.图像采集助手

打开相机采集图片

最小边缘幅度: 就是边缘的锯齿度

平滑:调节这个参数控制绿线往里面还是外面

ROI宽:调节绿线的长度

边缘由暗到亮为正向,边缘由亮到暗为负向

显示轮廓线

Y方向是像素值,X方向是像素

第一个陡坡像素值从200多降到十几,所用是第一个边缘,第二个陡坡从十几上升到200多,说明是第二个边缘。

对于结果,第一个点是负向边缘点多坐标,第二个点是正向边缘点的坐标,宽就是芯片的长度。

代码

  • Code generated by Measure 01
  • Prepare measurement
    AmplitudeThreshold := 40
    ROIWidth := 5
    set_system (‘int_zooming’, ‘true’)
  • Coordinates for line Measure 01 [0]
    LineRowStart_Measure_01_0 := 208.77
    LineColumnStart_Measure_01_0 := 106.167
    LineRowEnd_Measure_01_0 := 793.913
    LineColumnEnd_Measure_01_0 := 1002.67
  • Convert coordinates to rectangle2 type
    TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_0+LineRowEnd_Measure_01_0)
    TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_0+LineColumnEnd_Measure_01_0)
    TmpCtrl_Dr := LineRowStart_Measure_01_0-LineRowEnd_Measure_01_0
    TmpCtrl_Dc := LineColumnEnd_Measure_01_0-LineColumnStart_Measure_01_0
    TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
    TmpCtrl_Len1 := 0.5sqrt(TmpCtrl_DrTmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
    TmpCtrl_Len2 := ROIWidth
  • Create measure for line Measure 01 [0]
  • Attention: This assumes all images have the same size!
    gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 1280, 1024, ‘nearest_neighbor’, MsrHandle_Measure_01_0)

    • The code which follows is to be executed once / measurement *

  • Load image
    read_image (Image, ‘D:/废弃/1.png’)
  • Execute measurements
    measure_pairs (Image, MsrHandle_Measure_01_0, 1, 40, ‘all’, ‘all’, Row1_Measure_01_0, Column1_Measure_01_0, Amplitude1_Measure_01_0, Row2_Measure_01_0, Column2_Measure_01_0, Amplitude2_Measure_01_0, Width_Measure_01_0, Distance_Measure_01_0)
  • Do something with the results
  • Clear measure when done
    close_measure (MsrHandle_Measure_01_0)

文章作者: zhouhui
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 zhouhui !
  目录