zoukankan      html  css  js  c++  java
  • EmguCV 绘画图形

    1.Image类中绘图常用函数列表

    实践验证

    ///初始化图片

    private void Form1_Load(object sender, EventArgs e)

            {

                oldpic = new Emgu.CV.Image<Bgr, byte>(500, 400, new Bgr(Color.AliceBlue));

                pictureBox1.Image = oldpic.Bitmap;

            }

    /// 画-矩?形?

                Emgu.CV.Image<Bgr, byte> pic1 = oldpic.Clone();

                pic1.Draw(new Rectangle(100, 100, 120, 150), new Bgr(Color.Red), 5);

                pic1.Draw(new Rectangle(100, 100, 120, 150), new Bgr(Color.Red), 5, Emgu.CV.CvEnum.LineType.FourConnected, 1); //缩小为原来1/2,起点位置也一样

                pic1.Draw(new Rectangle(100, 100, 120, 150), new Bgr(Color.Red), 5, Emgu.CV.CvEnum.LineType.FourConnected, 2);//缩小为原来1/4,起点位置也一样

                pic1.Draw(new Rectangle(100, 100, 120, 150), new Bgr(Color.Red), 5, Emgu.CV.CvEnum.LineType.FourConnected, 3);//缩小为原来1/8,起点位置也一样

                pictureBox1.Image = pic1.Bitmap;

                pic1.Dispose();

    运行如下:

    画圆和椭圆类如画矩形 ,画文字

    Emgu.CV.Image<Bgr, byte> pic1 = oldpic.Clone();

                pic1.Draw(new CircleF(new PointF(100, 100), 50), new Bgr(Color.Red), 5);

                pic1.Draw(new Ellipse((RectangleF)(new Rectangle(100, 100, 120, 150))), new Bgr(Color.Red), 5); //注意类型转换

    string a = "OK";

    pic1.Draw(a, new Point(100, 250), Emgu.CV.CvEnum.FontFace.HersheyComplex, 5, new Bgr(Color.YellowGreen),5);

     

                pictureBox1.Image = pic1.Bitmap;

                pic1.Dispose();

    运行如下:

    工程实际用到画轮廓(根据点位进行),实际上又是调用画线的函数

    Point[] poi = new Point[6];

    Emgu.CV.Image<Bgr, byte> pic1 = oldpic.Clone();

                for (int i = 0; i < 6; i++)

                {

                    poi[i] = new Point(i * 50 + 50, i*i * 8 + 50);

    pic1.Draw(new Cross2DF(poi[i], 20, 20), new Bgr(Color.Black), 2);

                }

                pic1.Draw(poi, new Bgr(Color.Red),3,Emgu.CV.CvEnum.LineType.AntiAlias);

                pictureBox1.Image = pic1.Bitmap;

                pic1.Dispose();

    运行如下:

    绘制多线形跟画轮廓一样,主要看是否闭合,第二个参数不同

    pic1.DrawPolyline(poi,false, new Bgr(Color.Red), 3, Emgu.CV.CvEnum.LineType.AntiAlias);

    对于MAT类可以先转Image 绘完后再转回。

    特别指出在实际案例中会  统一一起绘制时采用此方式 int contourIdx 设定负数,全部一起

    public void Draw(IInputArray contours, int contourIdx, TColor color, int thickness = 1, LineType lineType = LineType.EightConnected, IInputArray hierarchy = null, int maxLevel = 2147483647, Point offset = null);

     

  • 相关阅读:
    隐式转换
    创建跟踪和查看执行计划需要的权限
    添加到SQLAgentReaderRole角色后报拒绝SELECT权限
    JS调试分享技巧
    很实用网站地址 CSS和JS,还有RGB
    数组去重,排序,重复次数,两个数组合并,两个数组去重,map(),filter(),reduce()
    动画可以暂停animation-play-state
    前端好的论坛地址
    CSS动画划入划出酷炫
    无题
  • 原文地址:https://www.cnblogs.com/nulidemaomaochong/p/8502611.html
Copyright © 2011-2022 走看看