Halcon 检测焊点短路
read_image (Image1, 'D:/image/bilibili/photo/检测焊接短路 (4).bmp')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_display (Image1)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
threshold (Image1, Region, 0, 80)
opening_circle (Region, RegionOpening, 3.5)
connection (RegionOpening, ConnectedRegions)
fill_up (ConnectedRegions, RegionFillUp)
connection (RegionFillUp, ConnectedRegions1)
select_shape (RegionFillUp, SelectedRegions, 'area', 'and',9174.31, 372477)
dev_display (Image1)
smallest_rectangle2 (SelectedRegions, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row-145, Column-5, Phi, Length1, Length2)reduce_domain (Image1, Rectangle, ImageReduced)
mean_image (ImageReduced, ImageMean, 9, 9)
threshold (ImageMean, Region1, 128, 255)
connection (Region1, ConnectedRegions2)
select_shape (ConnectedRegions2, SelectedRegions1, 'area', 'and', 0.86, 414)
sort_region (SelectedRegions1, SortedRegions, 'first_point', 'true', 'column')
count_obj (SortedRegions, Number)
flag:=0
dev_set_draw ('margin')
for Index := 1 to Number by 1select_obj (SortedRegions, ObjectSelected, Index)area_center (ObjectSelected, Area, Row1, Column1)if(Area>300)gen_circle (Circle, Row1, Column1, 20.5)flag:=flag + 1disp_message (WindowHandle, 'FALSE', 'Image1', 0, 0, 'red', 'true')endif
endfor
if(flag == 0)disp_message (WindowHandle, 'PASS', 'Image1', 0, 0, 'green', 'true')
endif