基於halcon的圓環寬度測量

2021-10-24 22:01:03 字數 2766 閱讀 5956

*1、建立測量模型

create_metrology_model (metrologyhandle)

*2、設定測量模型影象尺寸

set_metrology_model_image_size (metrologyhandle, width, height)

*3、增加測量模型物件

add_metrology_object_circle_measure (metrologyhandle, row, column, radius,20,

5,1.5,2,

,, circleindex)

*4、設定測量物件引數

*4.1 設定引數 每個物件尋找兩個

set_metrology_object_param (metrologyhandle, circleindex,

'num_instances',2

)*4.2 設定引數 每個物件查詢方式相同

set_metrology_object_param (metrologyhandle, circleindex,

'measure_transition'

,'uniform')*

5、進行測量

*6、獲得測量結果

get_metrology_object_result_contour (contour, metrologyhandle, circleindex,

'all'

,1.5)*

7、獲得測量區域(長條矩形)及邊緣點座標

get_metrology_object_measures (contours, metrologyhandle,

'all'

,'all'

, row1, column1)

*8、擬合物件

fit_circle_contour_xld (contour,

'algebraic',-

1,0,

0,3,

2, row2, column2, radius1, startphi, endphi, pointorder)

*9、使用x標記圓心

gen_cross_contour_xld (cross, row2, column2,4,

0.785398)*

10、顯示

color :=[

'red'

,'green'

,'blue'

]dev_display (image)

dev_set_line_width (1)

dev_set_color (color[1]

)dev_display (contours)

dev_set_color (color[0]

)dev_display (contour)

dev_display (cross)

dev_set_color (color[2]

)*獲取圓心陣列列座標的最大最小值

tuple_max (column2, max)

tuple_min (column2, min)

for i :

=1 to |radius1|

-1 by 2

if(column2[i]

<

(max+min)/2

) set_tposition (windowhandle, row2[i]

, column2[i]-2

*radius1[i]

-100

)else

set_tposition (windowhandle, row2[i]

, column2[i]+2

*radius1[i]

) endif

write_string (windowhandle,

'外-內r ='

+(radius1[i]

-radius1[i-1]

))endfor

dump_window (windowhandle,

'png'

,'內外徑差測量結果'

測量Dialog的寬度 高度

直接測量暫時沒有太好的解決方案,所以採用了曲線救國的策略。我們首先通過dialog.getwindow getdecorview 獲取到它的上層view,然後通過 view.measure measurespec.makemeasurespec 0,measurespec.unspecified m...

Halcon 測量 輪廓到線的距離

唯一需要注意的點就是 distance lc 這個運算元測量的是正交位置的點矩。count obj unioncontours,countobj tuple length rowbegin,counttuple if countobj counttuple for index 1 to counto...

Halcon基於輪廓的模板匹配

大家自己找張測試,就是繪製搜尋區域跟模板提取,提取其輪廓,然後再找一張相似的,從中定位到模板。話不多說,直接上 read image image1,d users s200722103 桌面 r1 f8y046205u1n639a1 038 20201109103715200.jpg dev set...