Halcon检测引脚弯曲
read_image (Image20231225150315, 'D:/image/bilibili/photo/屏幕截图 2023-12-25 150315.png')
dev_clear_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
decompose3 (Image20231225150315, Image1, Image2, Image3)
threshold (Image1, Region, 128, 255)
get_image_size (Image1, Width, Height)
gen_rectangle2 (Rectangle, Height/2-100, Width/2, 0, Width, 50)
reduce_domain (Image1, Rectangle, ImageReduced)
threshold (ImageReduced, Region1, 0, 128)
opening_circle (Region1, RegionOpening, 3.5)
connection (RegionOpening, ConnectedRegions)
count_obj (ConnectedRegions, Number)
sort_region (ConnectedRegions, SortedRegions, 'first_point', 'true', 'column')
*根据角度测量
for Index := 1 to Number by 1
select_obj (ConnectedRegions, ObjectSelected, Index)
inner_rectangle1 (ObjectSelected, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle1, Row1, Column1, Row2, Column2)
smallest_rectangle2 (ObjectSelected, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle2, Row, Column, Phi, Length1, Length2)
disp_message (WindowHandle, Phi, 'Image1', Row1, Column1, 'black', 'true')
endfor
*根据距离测量
for Index := 1 to Number-1 by 1
select_obj (ConnectedRegions, ObjectSelected, Index)
area_center (ObjectSelected, Area, Row3, Column3)
select_obj (ConnectedRegions, ObjectSelected, Index+1)
area_center (ObjectSelected, Area, Row4, Column4)
distance_pp (Row3, Column3, Row4, Column4, Distance)
gen_region_line (RegionLines, Row3, Column3, Row4, Column4)
disp_message (WindowHandle, Distance, 'Image1', Row3, Column3, 'black', 'true')
endfor