EmguCv“线段” 结构类型学习

1. 文件所在

Namespace: Emgu.CV.Structure
Assembly: Emgu.CV (in Emgu.CV.dll) Version: 3.0.0.2157 (3.0.0.2157)

类型分:LineSegment2D 、 LineSegment2DF、 LineSegment3DF

  1. 2.     函数说明:

2.1构造函数:LineSegment2DF

 

测试夹角的验证:画线确认之间夹角

部分代码:

Point[] a = new Point[2];  //构造线的点数组

        LineSegment2DF [] lin1=new LineSegment2DF [2]; 线段的数组

        int lin_num = 0; //线段数字超下标

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)

        {

           

            if (e.Button == MouseButtons.Left)

            {

                if (butleft_num < 2)  //

                {

 

                    ++butleft_num;

                    a[butleft_num - 1] = e.Location;

                }

                if (butleft_num> 2)

                {

                    butleft_num = 0;

                }

                if (butleft_num == 2)

                {

                    if (lin_num < 2)

                    {

                        ++lin_num;

                       

                        lin1[lin_num - 1]

                                = new LineSegment2DF(a[0], a[1]);

                    }

                    Graphics g1 = pictureBox1.CreateGraphics(); // 画图

                    g1.DrawLine(new Pen(Color.Red,5), a[0], a[1]); 画线

                    g1.Dispose();

                    butleft_num = 0;

                    if (lin_num==2)

                    {

                        label1.Text = lin1[1].GetExteriorAngleDegree(lin1[0]).ToString(); //验证角度计算

                    }

                    if (lin_num>=2)

                    {

                        lin_num = 0;

                    }

                }

            }

        }

 

posted on 2018-02-27 20:32  努力的毛毛虫  阅读(776)  评论(1编辑  收藏  举报

导航