halcon指令碼根據硬幣估計圓形面積

2021-09-23 10:47:52 字數 1731 閱讀 5973

根據硬幣測試圓形物體面積

* image acquisition 01: code generated by image acquisition 01

open_framegrabber ('directshow', 1, 1, 0, 0, 0, 0, 'default', 8, 'gray', -1, 'false', 'default', '[1] ', 0, -1, acqhandle)

grab_image_start (acqhandle, -1)

dev_close_window ()

dev_open_window (0, 0, 512, 512, 'black', windowid)

while (true)

grab_image_async (image, acqhandle, -1)

gauss_filter (image, imagegauss, 7)

threshold (imagegauss, regions, 44, 239)

connection (regions, connectedregions)

fill_up (connectedregions, regionfillup)

select_shape (regionfillup, selectedregions, 'area', 'and', 75229.4, 2e+006)

select_shape (selectedregions, selectedregions1, 'area', 'and', 0, 701835)

smallest_circle (selectedregions1, row, column, radius)

coin_r := radius

coin_area := pow(coin_r,2) * 3.1415926

area_rate := coin_area/4.90625

r_rate := coin_r/1.25

select_shape (selectedregions, selectedregions2, 'area', 'and', 133945, 2e+006)

smallest_circle (selectedregions2, row1, column1, radius1)

odj_r := radius1

obj_area := pow(odj_r,2)*3.1415926

obj_rel_r := odj_r/r_rate

obj_rel_area := obj_area / area_rate

obj_r_area := pow(obj_rel_r,2)*3.1415926

error := obj_rel_r / obj_r_area

dev_display (image)

disp_message (windowid, '物體的直徑(畫素比例推導):'+obj_rel_r+'\n由直徑計算的物體面積:'+obj_r_area+'\n由畫素比例計算物體的面積:'+obj_rel_area + '\n誤差:'+error+'\n注:物體的面積與直徑為分開測量,面積不是由直徑得到,是根據畫素比例計算', 'window', 0, 0, 'black', 'true')

endwhile

close_framegrabber (acqhandle)收起

halcon測量硬幣真實直徑

2019.3.10 9 25am熟練掌握halcon相機標定,理解其意義並且知道如何應用內外引數。在這個問題中,首先要測出硬幣在影象中的畫素尺寸,然後通過相機引數以及相關運算元得到硬幣在世界座標系下的真實直徑。1.halcon進行相機標定 2.對硬幣影象進行處理 3.處理後的影象擬合圓得到畫素直徑 ...

halcon運算元之如何根據特徵過濾區域和XLD

dev open window 0,0,512,512,black windowhandle read image image,fabrik threshold image,region,128,255 計算區域的連通分量。connection region,connectedregions 根據面...

根據metalink指令碼學習undo(四)

下面這個指令碼是顯示哪些活動事務占用undo空間 set lines 200 set pages 999 clear col set termout off set trimout on set trimspool on remrem current transactions remrem will...