halcon在视窗上的简单操作(线)
By
admin
at 2018-02-01 • 0人收藏 • 2073人看过
画一条线:
disp_line — Draws lines in a window.
dev_close_window () dev_open_window (0, 0, 512, 512, 'white', WindowID) RowA1 := 255 ColumnA1 := 10 RowA2 := 255 ColumnA2 := 501 dev_set_color ('red') disp_line (WindowID, RowA1, ColumnA1, RowA2, ColumnA2)
那么我们画一个四方块吧:(就是画四条相接的线段)
/* Display contour of a rectangle */ disp_rectangle1_margin(Hlong WindowHandle, Hlong Row1, long Column1, Hlong Row2, long Column2) { disp_line(WindowHandle,Row1,Column1,Row1,Column2) ; disp_line(WindowHandle,Row1,Column2,Row2,Column2) ; disp_line(WindowHandle,Row2,Column2,Row2,Column1) ; disp_line(WindowHandle,Row2,Column1,Row1,Column1) ; }
3 个回复 | 最后更新于 2018-02-03
* Calculate the distances between one line segment and one line * dev_close_window () dev_open_window (0, 0, 512, 512, 'white', WindowID) dev_set_color ('black') RowLine1 := 400 ColLine1 := 200 RowLine2 := 200 ColLine2 := 400 Rows := 300 Columns := 50 disp_line (WindowID, RowLine1, ColLine1, RowLine2, ColLine2) dev_set_color ('green') n := 0 for Rows := 40 to 200 by 4 distance_sl (Rows + n, Columns + n, Rows, Columns + n, RowLine1, ColLine1, RowLine2, ColLine2, DistanceMin, DistanceMax) if (DistanceMin <= 0) dev_set_color ('green') else dev_set_color ('red') endif disp_line (WindowID, Rows + n, Columns + n, Rows, Columns + n) n := n + 10 endfor
计算两根线之间的最小和最大距离:
distance_sl (Rows + n, Columns + n, Rows, Columns + n, RowLine1, ColLine1, RowLine2, ColLine2, DistanceMin, DistanceMax)
返回的是最小和最大的距离
以上代码是如果两根线最小距离小于0即:如果两根线相交,那么就设为绿色,上述代码有个bug,最后一根没相交的也是绿色的....
登录后方可回帖
画一条线:
计算两条线之间的角度(弧度):
弧度转角度: