Halcon_Operation_Note_HuangXiaoYu


2019-07-23

简单获取目标区域:

 1 dev_close_window ()
 2 dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
 3 
 4 dev_open_file_dialog ('read_image', 'default', 'default', Selection)
 5 read_image (MyImage, Selection)
 6 
 7 rgb1_to_gray (MyImage, GrayImage)
 8 threshold (GrayImage, Regions1, 209, 255)
 9 
10 
11 connection (Regions1, ConnectedRegions)
12 select_shape (ConnectedRegions, SelectedRegions1, 'area', 'and', 7981.65, 12128.4)
13 
14 
15 area_center (SelectedRegions1, Area, Row, Column)
16 disp_message (WindowHandle,Area+'---'+Row+'---'+Column , 'window', Row, Column, 'black', 'true')

2019-07-23

计算每个区域的面积,并保存到本地txt;

dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)

dev_open_file_dialog ('read_image', 'default', 'default', Selection)
read_image (MyImage, Selection)

regiongrowing (MyImage, Regions, 3, 3, 6, 100)
count_obj (Regions, Number)
open_file ('D:/Pic_Halcon_Avs_Vs/Information.txt', 'output', FileHandle)

for Index := 1 to Number by 1
    select_obj (Regions, ObjectSelected, Index)
    area_center (ObjectSelected, Area, Row, Column)
    fwrite_string (FileHandle, Index+'---'+Area)
    fnew_line (FileHandle)
    
    
    
endfor

close_file (FileHandle)

相关