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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓

發布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

HALCON示例程序find_pads.hdev通過fit_rectangle2_contour_xld繪制精準輪廓

示例程序源碼(加注釋)

  • 關于顯示類函數解釋
    dev_update_pc (‘off’)
    dev_update_window (‘off’)
    dev_update_var (‘off’)
    read_image (Image, ‘die_pads’)
    dev_close_window ()
    get_image_size (Image, Width, Height)
    dev_open_window (0, 0, Width * 2, Height * 2, ‘black’, WindowHandle)
    dev_set_part (0, 0, Height - 1, Width - 1)
  • fast_threshold - 使用全局閾值快速閾值處理圖像。
  • fast_threshold(圖片:區域:最小灰度值,最大灰度值,最小閾值分割值:)
    fast_threshold (Image, Region, 180, 255, 20)
  • 分割連通域
    connection (Region, ConnectedRegions)
  • 使面積與長短軸比值篩選區域
    select_shape (ConnectedRegions, SelectedRegions, [‘area’,‘anisometry’], ‘and’, [200,1], [1200,2])
    fill_up (SelectedRegions, RegionFillUp)
  • 求取最大邊界
    shape_trans (RegionFillUp, RegionTrans, ‘convex’)
  • boundary - 將區域縮小到其邊界。
  • boundary(區域:區域邊界:邊界種類 ?
    boundary (RegionTrans, RegionBorder, ‘inner’)
  • 使用圓形元素對區域進行膨脹
    dilation_circle (RegionBorder, RegionDilation, 2.5)
    union1 (RegionDilation, RegionUnion)
  • 減少圖片定義域
    reduce_domain (Image, RegionUnion, ImageReduced)
  • 求取邊界
    edges_sub_pix (ImageReduced, Edges, ‘sobel_fast’, 0.5, 20, 40)
  • 使用長度篩選邊界
    select_shape_xld (Edges, SelectedContours, ‘contlength’, ‘and’, 10, 200)
  • union_adjacent_contours_xld - 計算端點靠近的輪廓的并集。
  • union_adjacent_contours_xld(邊緣:合并邊緣:最大絕對距離,最大長度相對距離,模式:)
    union_adjacent_contours_xld (SelectedContours, UnionContours, 2, 1, ‘attr_keep’)
  • fit_rectangle2_contour_xld - 擬合XLD輪廓為矩形。
    fit_rectangle2_contour_xld (UnionContours, ‘tukey’, -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder)
  • gen_rectangle2_contour_xld - 創建矩形形狀的XLD輪廓。
    gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
    dev_display (Image)
    dev_set_colored (12)
    dev_display (Rectangle)

處理思路

這個例子是主要講解了如何利用邊緣提取與矩形擬合進行精確定位。使用了fast_threshold進行閾值分割,boundary并dilation_circle得到邊界圖像,使用edges_sub_pix進行邊緣提取,select_shape_xld篩選邊界,fit_rectangle2_contour_xld邊界矩形擬合,gen_rectangle2_contour_xld繪制邊緣輪廓。

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

總結

以上是生活随笔為你收集整理的HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓的全部內容,希望文章能夠幫你解決所遇到的問題。

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