Halcon 1D測量


1.產生測量句柄,准備提取與矩形(圓弧)主軸垂直的值邊緣。

gen_measure_rectangle2或gen_measure_arc

2.測量邊緣對   ,測量的直線與矩形或者圓弧垂直

measure_pairs (Image, MeasureHandle, 1.5, 30, 'negative', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, PinWidth, PinDistance)

measure_pairs適用於有許多組邊緣的圖像,如果是一組邊緣,也可以用measure_pos,下面的第一個例子就可以。使用他們時邊緣要是一條直線,結果中包含了許多信息,每一個邊緣RowEdge表示的是邊緣的行坐標,ColumnEdge表示的是列坐標,Amplitude表示的是根據Transition邊緣的梯度,IntraDistance表示的是一個邊緣組之間的距離,InterDistance表示的是邊緣組之間的距離,這兩個距離可以計算物體的高度和計算物體的個數

Transition = ‘negative’時表示由像素值高轉到低像素值的邊緣放在RowEdgeFirst中,這里有一個參考方向,就是Rectangle旋轉角度為0時,從左到右的方向

Sigma表示高斯濾波的參數,高斯濾波的是對Profile形成的曲線,Threshold是對他的一階導數設置的閾值(下圖粗線是Profile line經過的像素,細線是他的一階導數,可以看出它大概有三組邊緣)

如果要可視化邊緣,需要利用RowEdge,Column,Phi自己確定邊緣的開始點與結束點

 

注意,由於沒有對攝像機進行標定,1D測量只能獲得物體的像素的個數

3.測量邊緣與測量句柄矩形的交點  

measure_pos (Image, MeasureHandle, 1.5, 30, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)

4.直線擬合

fit_line_contour_xld( Contours : : Algorithm, MaxNumPoints, ClippingEndPoints, Iterations, ClippingFactor : RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist )

5.計算直線的交點

 

intersection_lines( : : Line1Row1, Line1Column1, Line1Row2, Line1Column2, Line2Row1, Line2Column1, Line2Row2, Line2Column2 : Row, Column, IsOverlapping)

6.計算兩點的距離

 

distance_pp( : : Row1, Column1, Row2, Column2 : Distance)

7.計算線的方向(角度)

 

line_orientation( : : RowBegin, ColBegin, RowEnd, ColEnd : Phi)

8.計算線與水平軸間的夾角

angle_lx( : : Row1, Column1, Row2, Column2 : Angle)

 

 

函數作用:

逆時針旋轉向量到水平軸的角度即為結果值,該結果取決於兩個點的順序,用弧度表示,范圍為[-pi, pi]

 

 

 

參數列表:

Row1(in):線起始點的行坐標

Column1(in):線起始點的列坐標

Row2(in):線終止點的行坐標

Column2(in):線終止點的列坐標

Angle(out):線與水平軸的夾角

 

可能替代項:

angle_ll

 


免責聲明!

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



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