绘图
class Program { static void Main(String[] args) { Mat img = new Mat(600, 400, DepthType.Cv8U, 3); img.SetTo(new Bgr(0, 0, 0).MCvScalar); //绘制一条黄色,线宽为4 的反锯齿线段 CvInvoke.Line(img, new Point(10, 10), new Point(100, 250), new MCvScalar(0, 255, 255),4,LineType.AntiAlias); //绘制圆心为200,100,半径为50,线宽为15的红色空心圆 CvInvoke.Circle(img, new Point(200, 100), 50, new MCvScalar(0, 0, 255), 15, LineType.AntiAlias); //绘制左上角200,300宽高为150,100的绿色矩形框 CvInvoke.Rectangle(img, new Rectangle(200, 300, 150, 100), new MCvScalar(0, 255, 0), 1); //绘制中心为200,200,大小为150,120,旋转40度,颜色为cyan的椭圆 CvInvoke.Ellipse(img, new RotatedRect(new Point(200, 200), new Size(150, 120), 40), new MCvScalar(255, 255, 0), 3); //绘制文字 CvInvoke.PutText(img, "CTC", new Point(100, 100), FontFace.HersheyComplex, 3, new MCvScalar(0, 255, 255), 2); CvInvoke.Imshow("draw", img); CvInvoke.WaitKey(0); } }
效果
使用鼠标绘制矩形