1. 程式人生 > >halcon 尋找圓,半徑和圓心

halcon 尋找圓,半徑和圓心

dev_close_window ()
dev_update_window ('off')
read_image (Image, 'D:/mywindows/circle.bmp')

get_image_size (Image, Width1, Height1)

dev_open_window(0, 0, Width1, Height1, 'black', WindowHandle) 
dev_display(Image)

rgb1_to_gray (Image, GrayImage)
gauss_filter (GrayImage, ImageGauss, 7)
gen_rectangle1 (ROI_0, 0, 0, Height1, Width1)
reduce_domain (ImageGauss, ROI_0, ImageReduced)
roberts (ImageReduced, ImageRoberts, 'gradient_sum')
threshold (ImageRoberts, Regions, 0, 28)
connection (Regions, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 0, 90185.2)
shape_trans (SelectedRegions, RegionTrans, 'outer_circle')
* 可以將缺損的圓補全
area_center (RegionTrans, Area, Row, Column)
*計算半徑  
Radius:=sqrt(Area/3.1415926)

 

 

參考:https://blog.csdn.net/pudongdong/article/details/52484974