halcon xld線段中點、端點和角度的計算


一、xld線段中點

area_center_points_xld (Line4, Area, Row, Column)


二、xld線段端點

*xld轉region
gen_region_contour_xld (LineContours, RegionLines, 'filled')
*提取區域輪骨
skeleton (RegionLines, Skeleton)
*獲取輪骨端點
junctions_skeleton (RegionLines, EndPoints, JuncPoints)
get_region_points (EndPoints, Rows1, Columns1)



三、xld線段角度

法一:可將xld轉成區域,然后求區域的方向

gen_region_contour_xld (LineContours, RegionLines, 'filled')
orientation_region (RegionLines, Phi)


法二:直接求xld輪廓方向

orientation_xld(XLD : : : Phi)

法三:通過求橢圓長半軸、短半軸的方式求xld輪廓(精度較高,但是方向有時會找不准)

elliptic_axis_points_xld(XLD : : : Ra, Rb, Phi)

法三:通過線段兩端點的反正切來求角度(方向准確,精度較高,始終以X軸正方向為起始方向,推薦)

注:直線起始端點(Rows[0],Columns[0]),末尾端點(Rows[1],Columns[1])

offsetX := RightDownColumn - LeftUpColumn
offsetY := RightDownRow - LeftUpRow
tuple_atan2 (offsetY, offsetX, angel)
tuple_deg (angel, angelDeg)
*線段與X軸正方向的夾角
m_rotate := 180 - angelDeg


免責聲明!

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



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