角度计算方式:将直线看作向量(有方向性),以直线与水平轴的交点为起点(旋转中心)。如果终点在水平轴上方,则夹角为逆时针旋转水平轴到向量的角度(带正号)。如果终点在水平轴下方,则夹角为顺时针旋转水平轴到向量的角度(带负号)。结果取决于定义线条的两点的顺序。
角度表示方式:弧度,-π<=Angle<π
dev_close_window() dev_open_window (0, 0, 512, 512, 'black', WindowHandle) Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row1, Col1, 25, 15) dev_set_color ('yellow') gen_region_line (ROI_0, 350, 100, 350, 750) XRowHalf := 350 XColHalf := (100 + 700)/2 gen_arrow_contour_xld (Arrow, XRowHalf, XColHalf,350, 750, 25, 15) angle_lx (Row2, Col2, Row1, Col1, Angle) disp_message (WindowHandle, '红色线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true') disp_message (WindowHandle, 'X', 'Image', 345, 765, 'yellow', 'false') stop() dev_clear_window() Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row2, Col2, 25, 15) dev_set_color ('yellow') gen_region_line (ROI_0, 350, 100, 350, 750) XRowHalf := 350 XColHalf := (100 + 700)/2 gen_arrow_contour_xld (Arrow, XRowHalf, XColHalf,350, 750, 25, 15) angle_lx (Row1, Col1,Row2, Col2, Angle) disp_message (WindowHandle, '红色线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true') disp_message (WindowHandle, 'X', 'Image', 345, 765, 'yellow', 'false')
讯享网
角度计算方式:该算子计算原理与angle_lx类似,只不过把水平轴替换为任意直线B
角度表示方式:弧度,-π<=Angle<=π
讯享网dev_close_window() dev_open_window (0, 0, 512, 512, 'black', WindowHandle) set_display_font (WindowHandle, 26, 'mono', 'true', 'false') Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 Row3 := 400 Col3 := 100 Row4 := 100 Col4 := 500 Row2Half := (Row3 + Row4)/2 Col2Half := (Col3 + Col4)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row1, Col1, 25, 15) dev_set_color ('blue') gen_region_line (RegionLines, Row3, Col3, Row4, Col4) gen_arrow_contour_xld (Arrow1, Row2Half, Col2Half, Row3, Col3, 25, 15) angle_ll (Row4, Col4,Row3, Col3, Row2, Col2,Row1, Col1, Angle) disp_message (WindowHandle, '蓝色线转向红色线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true') stop() dev_clear_window() Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 Row3 := 400 Col3 := 100 Row4 := 100 Col4 := 500 Row2Half := (Row3 + Row4)/2 Col2Half := (Col3 + Col4)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row1, Col1, 25, 15) dev_set_color ('blue') gen_region_line (RegionLines, Row3, Col3, Row4, Col4) gen_arrow_contour_xld (Arrow1, Row2Half, Col2Half, Row4, Col4, 25, 15) angle_ll (Row3, Col3, Row4, Col4, Row2, Col2,Row1, Col1, Angle) disp_message (WindowHandle, '蓝色线转向红色线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true') stop() dev_clear_window() Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 Row5 := 250 Col5 := 20 Row6 := 250 Col6 := 550 Row3Half := (Row5 + Row6)/2 Col3Half := (Col5 + Col6)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row1, Col1, 25, 15) dev_set_color ('yellow') gen_region_line (RegionLines, Row5, Col5, Row6, Col6) gen_arrow_contour_xld (Arrow1, Row3Half, Col3Half, Row6, Col6, 25, 15) angle_ll (Row2, Col2,Row1, Col1,Row5, Col5, Row6, Col6, Angle) disp_message (WindowHandle, '红色线转向黄**线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true') stop() dev_clear_window() Row1 := 100 Col1 := 100 Row2 := 500 Col2 := 600 Row1Half := (Row1 + Row2)/2 Col1Half := (Col1 + Col2)/2 Row5 := 250 Col5 := 20 Row6 := 250 Col6 := 550 Row3Half := (Row5 + Row6)/2 Col3Half := (Col5 + Col6)/2 dev_set_color ('red') gen_region_line (RegionLines, Row1, Col1, Row2, Col2) gen_arrow_contour_xld (Arrow1, Row1Half, Col1Half, Row1, Col1, 25, 15) dev_set_color ('yellow') gen_region_line (RegionLines, Row5, Col5, Row6, Col6) gen_arrow_contour_xld (Arrow1, Row3Half, Col3Half, Row6, Col6, 25, 15) angle_ll (Row5, Col5, Row6, Col6, Row2, Col2,Row1, Col1, Angle) disp_message (WindowHandle, '黄色线转向红色线角度为:' + deg(Angle), 'window', 12, 12, 'black', 'true')
角度计算方式:当直线(无方向性)大致位于1、3象限的方向,角度为正。当直线大致位于2、4象限的方向,角度为负。
角度表示方式:弧度,-π/2<Phi<=π/2
---
参考文献
Halcon的angle_ll和angle_lx角度的解析 - 木乔ni - 博客园

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/23716.html