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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

瓶子个数计数halcon

發布時間:2023/12/10 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 瓶子个数计数halcon 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 處理要求
  • 處理方法一
    • 源碼
    • 效果
  • 方法二
    • 源碼
    • 效果

  • 博主寫作不容易,孩子需要您鼓勵
  • 萬水千山總是情 , 先點個贊行不行

處理要求

查找紙箱內瓶子個數


處理方法一

源碼

dev_clear_window () dev_open_window (0, 0, 640*1.5, 512*1.5, 'black', WindowHandle) * Image Acquisition 01: Code generated by Image Acquisition 01 list_files ('F:/HALCON/瓶蓋識別/1', ['files','follow_links'], ImageFiles) tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles) for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])* Image Acquisition 01: Do somethingmean_image (Image, ImageMean, 19, 19)sub_image (ImageMean, Image, ImageSub, 1, 1)mean_image (ImageSub, ImageMean1, 19, 19)dyn_threshold (ImageSub, ImageMean1, RegionDynThresh, 4, 'light')connection (RegionDynThresh, ConnectedRegions)select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 711.57, 20000) select_shape (SelectedRegions, SelectedRegions1, ['width','height'], 'and', [0,0], [200,200])union1 (SelectedRegions1, RegionUnion)closing_circle (RegionUnion, RegionClosing, 20)fill_up (RegionClosing, RegionFillUp)difference (RegionFillUp, RegionClosing, RegionDifference)connection (RegionDifference, ConnectedRegions1) count_obj (ConnectedRegions1, Number)dev_display (Image)dev_display (ConnectedRegions1)set_display_font (WindowHandle, 50, 'mono', 'true', 'false')disp_message (WindowHandle, ['箱內有瓶:']+[Number], 'image', 30, 30, ['blue'], 'false') stop()endfor

效果



方法二

源碼

list_files ('F:/HALCON/瓶蓋識別/2', ['files','follow_links'], ImageFiles) tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles) for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])smooth_image(Image, ImageSmooth, 'deriche2', 0.5)edges_color_sub_pix(ImageSmooth, Edges, 'canny', 2, 10, 20)segment_contours_xld(Edges, ContoursSplit, 'lines_circles', 5, 5, 3)union_cocircular_contours_xld(ContoursSplit, UnionContours, 0.5, 0.1, 0.2, 30, 10, 10, 'true', 1)select_shape_xld (UnionContours, SelectedXLD1, ['ra','rect2_len1','circularity'], 'and', [15,30,0.3], [50,65,1])fit_circle_contour_xld(SelectedXLD1, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)gen_circle_contour_xld(ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)select_shape_xld (ContCircle, SelectedXLD, ['ra','area'], 'or', [36,3200], [50,5000])dev_display(Image)dev_display(SelectedXLD)stop() endfor

效果



------------------------------------------------------------------------------------------分割線 ------------------------------------------------------------------------------------------
  • 博主簡介:
  • 工業自動化上位機軟件工程師、機器視覺算法工程師、運動控制算法工程師。目前從業于智能制造自動化行業。 博主郵箱:2296776525@qq.com
  • 幫忙點個贊吧。哈哈。

總結

以上是生活随笔為你收集整理的瓶子个数计数halcon的全部內容,希望文章能夠幫你解決所遇到的問題。

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