halcon例程學習 一維測量之矩形邊緣


********************************************************************
*加載圖片
read_image (Image, 'ic_pin')
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_display (Image)
get_image_size (Image, Width, Height)

*********************************************************************
*選擇矩形區域

nRow := 47
nColoum := 485
nPhi  := 0
nLen1 := 420
nLen2 := 10

dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (2)

gen_rectangle2 (Rectangle, nRow, nColoum, nPhi, nLen1, nLen2)
***********************************************************************

*獲取矩形測量句柄
gen_measure_rectangle2 (nRow, nColoum, nPhi, nLen1, nLen2, Width, Height, 'nearest_neighbor', MeasureHandle)

*提取垂直於矩形或環形弧的直邊對
measure_pairs (Image, MeasureHandle, 1.5, 10, 'all', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)

close_measure (MeasureHandle)

gen_region_line (RegionLines, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond)

stop ()
*********************************************************************
*選擇矩形區域

nRow := 508
nColoum := 200
nPhi  := -1.57
nLen1 := 500
nLen2 := 10

dev_set_color ('yellow')
dev_set_draw ('margin')
dev_set_line_width (2)

gen_rectangle2 (Rectangle, nRow, nColoum, nPhi, nLen1, nLen2)
***********************************************************************

*獲取矩形測量句柄
gen_measure_rectangle2 (nRow, nColoum, nPhi, nLen1, nLen2, Width, Height, 'nearest_neighbor', MeasureHandle)

*獲取測量端點
measure_pos (Image, MeasureHandle, 1.5, 30, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)

gen_cross_contour_xld (Cross, RowEdge, ColumnEdge, 20, 0)

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM