只有一张图,没法测鲁棒性。用均值滤波算子筛选的。
- dev_update_off ()
- dev_close_window ()
- read_image (Image, 'E:/Users/laihuaxun/Desktop/halcon 学习资料/TEST Image/122029fj2s700b74e0jjaa.png')
- get_image_size (Image, Width, Height)
- dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
- dev_display (Image)
- *找到大圆
- threshold (Image, Region, 120, 255)
- smallest_circle (Region, Row, Column, Radius)
- *找两个小点
- mean_image (Image, ImageMean, 13, 13)
- dyn_threshold (Image, ImageMean, RegionDynThresh, 11, 'dark')
- connection (RegionDynThresh, ConnectedRegions)
- fill_up (ConnectedRegions, RegionFillUp)
- select_shape (RegionFillUp, SelectedRegions, ['area','inner_radius','outer_radius'], 'and', [100,4,6], [200,10,15])
- opening_circle (SelectedRegions, RegionOpening, 3.5)
- count_obj (RegionOpening, Number)
- if (Number#2)
- stop ()
- endif
- shape_trans (RegionOpening, RegionTrans, 'inner_circle')
- smallest_circle (RegionTrans, Row2, Column2, Radius1)
- gen_circle (Circle, Row2, Column2, Radius1)
- *测量角度
- angle_lx (Row, Column, Row2[0], Column2[0], Angle1)
- angle_lx (Row, Column, Row2[1], Column2[1], Angle2)
- *画扇形
- gen_circle_sector (CircleSector, Row, Column, Radius,rad(360)+Angle2,Angle1)
- dev_set_draw ('margin')
- dev_set_line_width (2)
- dev_display (Image)
- dev_display (Circle)
- dev_display (CircleSector)
复制代码
|