日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HALCON示例程序measure_ball_bond.hdev电路板焊点位置测量

發布時間:2023/12/10 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HALCON示例程序measure_ball_bond.hdev电路板焊点位置测量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

HALCON示例程序measure_ball_bond.hdev電路板焊點位置測量

示例程序源碼(加注釋)

  • 關于顯示類函數解釋
    dev_update_off ()
    dev_close_window ()
    FileName := ‘bonds/ball_bond_ccd_’
    read_image (Image, FileName + 1$‘02’)
    dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
    dev_set_line_width (2)
    set_display_font (WindowHandle, 16, ‘mono’, ‘true’, ‘false’)
    dev_set_draw (‘margin’)
    get_system (‘store_empty_region’, StoreEmptyRegion)
    set_system (‘store_empty_region’, ‘false’)
  • 定義變量并初始化
    NumImages := 6
    for Index := 1 to NumImages by 1
    read_image (Image, FileName + Index$‘02’)
    dev_display (Image)
    • 獲得運行時間
      count_seconds (S1)
    • 二值化
      threshold (Image, Region, 135, 255)
    • 分割連通域
      connection (Region, ConnectedRegions)
    • 使用寬度高度面積進行區域篩選
      select_shape (ConnectedRegions, SelectedRegions, [‘width’,‘height’,‘area’], ‘and’, [115,115,5000], [130,130,15000])
      fill_up (SelectedRegions, RegionFillUp)
      shape_trans (RegionFillUp, Pads, ‘convex’)
    • 求取內孔區域
      difference (Pads, RegionFillUp, RegionDifference)
    • 開運算
      opening_rectangle1 (RegionDifference, BondWire, 10, 10)
    • 求取最大內切圓
      shape_trans (BondWire, BallBonds, ‘inner_circle’)
    • select_shape_proto基于區域之間的某些關系選擇區域,這里使用重疊區域
    • select_shape_proto(測量區域,對比區域:篩選出的區域:關系,最小值,最大值:)
      select_shape_proto (Pads, BallBonds, MissingBonds, ‘overlaps_rel’, 0, 0)
      count_seconds (S2)
      Time := (S2 - S1) * 1000
    • 膨脹
      dilation_circle (BallBonds, RegionDilation2, 10)
    • 求交集
      intersection (RegionDilation2, BondWire, RegionIntersection)
    • 求邊緣的老方法了,之前的貼子傳送門
      boundary (RegionIntersection, RegionBorder, ‘inner’)
      dilation_circle (RegionBorder, RegionDilation, 3.5)
      union1 (RegionDilation, RegionUnion)
      reduce_domain (Image, RegionUnion, ImageReduced)
      edges_sub_pix (ImageReduced, Edges, ‘canny’, 1, 20, 70)
    • union_adjacent_contours_xld - 計算端點靠近的輪廓的并集。
    • union_adjacent_contours_xld(邊緣:合并的邊緣:端點最大絕對閾值,端點最大相對閾值,模式:)
      union_adjacent_contours_xld (Edges, UnionContours, 10, 1, ‘attr_keep’)
    • 篩選XLD輪廓
      select_contours_xld (UnionContours, SelectedContours, ‘contour_length’, 20, 20000, -0.5, 0.5)
    • 通過XLD輪廓擬合圓形
      fit_circle_contour_xld (SelectedContours, ‘atukey’, -1, 0, 0, 5, 7, CircleRow, CircleColumn, Radius, StartPhi, EndPhi, PointOrder)
    • 繪制XLD輪廓圓形
      gen_circle_contour_xld (ContCircle, CircleRow, CircleColumn, Radius, 0, 6.28318, ‘positive’, 1)
      count_obj (BondWire, NBonds)
      gen_empty_obj (MeasureArrows)
    • 下邊這些就非常簡單的啦
      dev_display (Image)
      dev_set_color (‘cyan’)
      dev_display (ContCircle)
      dev_set_color (‘magenta’)
      area_center (RegionDilation2, Area, Row, Column)
      area_center (MissingBonds, AreaM, RowM, ColumnM)
      select_shape_proto (Pads, BallBonds, BallTooClose, ‘distance_contour’, 0, 10)
      area_center (BallTooClose, AreaB, RowB, ColumnB)
      dev_set_color (‘yellow’)
      dev_display (Pads)
      if (|AreaM| > 0 or |AreaB| > 0)
      dev_set_color (‘red’)
      dev_display (MissingBonds)
      dev_display (BallTooClose)
      for IndexE := 0 to |AreaM| - 1 by 1
      NRow := RowM[IndexE]
      NCol := ColumnM[IndexE]
      disp_message (WindowHandle, ‘Ball bond\nis missing’, ‘image’, NRow - 150, NCol - 110, ‘red’, ‘true’)
      endfor
      for IndexE := 0 to |AreaB| - 1 by 1
      NRow := RowB[IndexE]
      NCol := ColumnB[IndexE]
      disp_message (WindowHandle, ‘Ball bond is too\nclose to border’, ‘image’, NRow - 150, NCol - 150, ‘red’, ‘true’)
      endfor
      endif
      for IndexM := 1 to NBonds by 1
      select_obj (ContCircle, ObjectSelected, IndexM)
      • 求取XLD輪廓的最小外接矩形
        smallest_rectangle1_xld (ObjectSelected, minY, minX, maxY, maxX)
      • 求取XLD輪廓中心
        area_center_xld (ObjectSelected, Area1, Ybb, Xbb, PointOrder1)
      • 繪制XLD箭頭
        gen_arrow_contour_xld (Arrow, Ybb, Xbb, minY, Xbb, 12, 12)
        concat_obj (MeasureArrows, Arrow, MeasureArrows)
        gen_arrow_contour_xld (Arrow, Ybb, Xbb, maxY, Xbb, 12, 12)
        concat_obj (MeasureArrows, Arrow, MeasureArrows)
        dev_set_color (‘green’)
        dev_display (MeasureArrows)
        select_obj (ContCircle, ObjectSelected, IndexM)
        area_center_xld (ObjectSelected, Area2, Ybb, Xbb, PointOrder2)
        disp_message (WindowHandle, (2 * Radius[IndexM - 1])KaTeX parse error: Expected 'EOF', got '\nin' at position 129: …ond(s) detected\?n?i?n? ?' + Time’.2f’ + ’ ms’, ‘window’, 12, 12, ‘black’, ‘true’)
    • Evaluate and display results
      if (Index != NumImages)
      disp_continue_message (WindowHandle, ‘black’, ‘true’)
      stop ()
      endif
      endfor
      set_system (‘store_empty_region’, StoreEmptyRegion)

處理思路

這個例子是主要講解了使用blob分析方法,結合XLD輪廓擬合,對電路焊點的檢測與測量。count_seconds計時算子select_shape_proto、union_adjacent_contours_xld、select_contours_xld、fit_circle_contour_xld、gen_circle_contour_xld、gen_arrow_contour_xld、smallest_rectangle1_xld、area_center_xld、gen_arrow_contour_xld

后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。

總結

以上是生活随笔為你收集整理的HALCON示例程序measure_ball_bond.hdev电路板焊点位置测量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。