內容源自:html
*對目標進行排序
*http://www.ihalcon.com/read-15537.html
rest
重點關注:code
union1 (SelectedRegions, RegionUnion) ///區域合併htm
sort_region (RegionAffineTrans, SortedRegions, 'character', 'true', 'row') ///排序排序
完整的源碼:get
*對目標進行排序 *http://www.ihalcon.com/read-15537.html dev_close_window() dev_update_off() read_image (Image, '對目標進行排序.bmp') get_image_size (Image, Width, Height) dev_open_window (0, 0, Width/1.5, Height/1.5, 'black', WindowHandle) dev_display (Image) threshold (Image, Region, 0, 30) connection (Region, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 200, 600) union1 (SelectedRegions, RegionUnion) ///區域合併 smallest_rectangle2 (RegionUnion, Row, Column, Phi, Length1, Length2) gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2) vector_angle_to_rigid (Row, Column, 0, Row, Column, -Phi, HomMat2D) vector_angle_to_rigid (Row, Column, 0, Row, Column, Phi, HomMat2D1) affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false') affine_trans_region (SelectedRegions, RegionAffineTrans, HomMat2D, 'nearest_neighbor') sort_region (RegionAffineTrans, SortedRegions, 'character', 'true', 'row') ///排序 affine_trans_region (SortedRegions, RegionAffineTrans1, HomMat2D1, 'nearest_neighbor') dev_display (Image) count_obj (RegionAffineTrans1, Number) for i:=1 to Number by 1 select_obj (RegionAffineTrans1, ObjectSelected, i) area_center (ObjectSelected, Area, Row1, Column1) dev_disp_text (i, 'image', Row1, Column1, 'red', 'box', 'false') endfor