Halcon求角度
*读取图像
read_image (Image, 'D:/image/bilibili/photo/示例轮廓.bmp')
binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)
*找到最外围大圆
connection (Region, ConnectedRegions)
fill_up (ConnectedRegions, RegionFillUp)
opening_circle (RegionFillUp, RegionOpening, 13.5)
select_shape (RegionOpening, SelectedRegions1, ['area','circularity'], 'and', [145872,0.6725], [856215,1])
smallest_circle (SelectedRegions1, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
reduce_domain (Image, Circle, ImageReduced1)
*找到里面小圆
binary_threshold (Image, Region1, 'max_separability', 'light', UsedThreshold1)
connection (Region1, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions2, 'area', 'and', 31605.5, 50000)
opening_circle (SelectedRegions2, RegionOpening1, 60)
inner_circle (RegionOpening1, Row1, Column1, Radius1)
gen_circle (Circle1, Row1, Column1, Radius1)
reduce_domain (Image, Circle1, ImageReduced)
*抠图获取中间圆环,然后获取突起点的圆
difference (Circle, Circle1, RegionDifference)
reduce_domain (Image, RegionDifference, ImageReduced2)
binary_threshold (ImageReduced2, Region2, 'max_separability', 'light', UsedThreshold2)
connection (Region2, ConnectedRegions2)
opening_circle (ConnectedRegions2, RegionOpening2, 13.5)
select_shape (RegionOpening2, SelectedRegions, 'area', 'and', 4429.5, 5000)
smallest_circle (SelectedRegions, Row3, Column3, Radius3)
gen_circle (Circle2, Row3, Column3, Radius3)
*画线
gen_region_line (RegionLines, Row1, Column1, Row3, Column3)
angle_lx (Row1, Column1, Row3, Column3, Angle)
*角度转换
tuple_deg (Angle, Deg)
set_draw (200000, 'margin')
dev_display (Image)
dev_display (Circle)
dev_display (Circle1)
dev_display (RegionLines)
disp_message (200000, Deg, 'Image', Row3, Column3, 'black', 'true')