基本绘图函数
- 主要作用:标记,结果输出
EmguCV常用绘图函数:
CvInvoke.Line()//------用于绘制直线
CvInvoke.Circle()//函数------用于绘制圆
CvInvoke.Rectangle()//函数------用于绘制矩形
CvInvoke.Ellipse()//函数------用于绘制椭圆
CvInvoke.PutText()//函数------用于添加文字
绘制直线-----CvInvoke.Line()
Line(IIputOutputArray img,Point pt1,Point pt2,MCvScalar color,int thickess=1,LineType lineType= LineType.EightConnected,int shift =0);
-
第一个参数:要绘制在哪个图像上;
-
第二第三个参数:起点和端点;
-
第四个参数:直线的颜色;
-
第五个参数:直线的宽度:单位:像素
-
第六个参数:有好几种类型;
-
int shift:不常使用
例子
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using Emgu.Util;
namespace drawing_basic
{
class Program
{
static void Main(string[] args)
{
//创建一个500*500的黑色图像
Mat img = new Mat(500, 500, DepthType.Cv8U, 3);
img.SetTo(new MCvScalar(0, 0, 0));
//在img上面绘制一条直线
CvInvoke.Line(img, new Point(100, 100), new Point(200, 200), new MCvScalar(0, 155, 0), 2, LineType.EightConnected);
//把图片显示出来
CvInvoke.Imshow("img", img);
CvInvoke.WaitKey(0);
}
}
}
绘制圆-----CvInvoke.Circle()
Circle(IIputOutputArray i