halcon定位熊猫型保偏光纤轴心
By
admin
at 2018-02-01 • 0人收藏 • 1626人看过
* Image Acquisition 01: Code generated by Image Acquisition 01 dev_close_window () read_image (Image, 'C:/Users/RD-W/Desktop/猫眼光纤/298A2EDD810F80896AF853AFDF8EA5EF.jpg') dev_open_window_fit_image(Image, 0, 0, -1, -1, WindowHandle) *dev_set_draw ('margin') dev_display (Image) *decompose3 (Image, Image1, Image2, Image3) rgb1_to_gray (Image, GrayImage) mean_image (GrayImage, ImageMean, 9, 9) scale_image (ImageMean, ImageScaled, 1.44068, 0) threshold (ImageScaled, Regions, 0, 213) connection (Regions, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 839518, 5e+006) *select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 792683, 1e+006) closing_circle (SelectedRegions, RegionClosing, 50) *opening_circle (SelectedRegions, RegionOpening, 3.5) fill_up (RegionClosing, RegionFillUp) smallest_circle (RegionFillUp, Row, Column, Radius) dev_display (GrayImage) dev_set_color ('green') gen_circle (Circle, Row, Column, Radius) *disp_circle (WindowHandle, Row, Column, Radius) gen_cross_contour_xld (Cross, Row, Column, 100, 0.785398) dev_set_draw ('fill') dev_set_color ('red') reduce_domain (ImageMean, Circle, ImageReduced) threshold (ImageReduced, Regions1, 131, 255) opening_circle (Regions1, RegionOpening, 50) connection (RegionOpening, ConnectedRegions1) fill_up (ConnectedRegions1, RegionFillUp1) manrow := [] mancolumn := [] mancross := [] manrad := [] select_shape (RegionFillUp1, SelectedRegions1, 'area', 'and', 79449.5, 500000) *select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 79449.5, 100000) for Index := 1 to 2 by 1 select_obj (SelectedRegions1, ObjectSelected, Index) opening_circle (ObjectSelected, RegionOpening1, 20) dev_set_color ('green') shape_trans (RegionOpening1, RegionTrans, 'outer_circle') smallest_circle (RegionTrans, Row1, Column1, Radius1) *area_center (RegionTrans, Area, Row1, Column1) *dev_set_color ('white') manrow[Index] := Row1 mancolumn[Index] := Column1 manrad[Index] := Radius1 *gen_cross_contour_xld (Cross1, Row1, Column1, 100, 0.785398) endfor gen_circle (Circle1, manrow, mancolumn, manrad) dev_clear_window () dev_display (Image) dev_set_draw ('margin') dev_set_color ('orange red') dev_set_line_width (3) dev_display (Circle) dev_display (Circle1) dev_display (Cross) gen_cross_contour_xld (Cross2, manrow, mancolumn, 100, 0.785398) dev_display (Cross2) gen_region_line (RegionLines, manrow[1], mancolumn[1], manrow[2], mancolumn[2])
登录后方可回帖