0.5-OpenCvSharp4绘制形状和文字

    科技2022-07-11  106

    0.5 OpenCvSharp4绘制形状和文字

    // // 摘要: // Draws a line segment connecting two points // // 参数: // img: // The image. // // pt1X: // First point's x-coordinate of the line segment. // // pt1Y: // First point's y-coordinate of the line segment. // // pt2X: // Second point's x-coordinate of the line segment. // // pt2Y: // Second point's y-coordinate of the line segment. // // color: // Line color. // // thickness: // Line thickness. [By default this is 1] // // lineType: // Type of the line. [By default this is LineType.Link8] // // shift: // Number of fractional bits in the point coordinates. [By default this is 0] public static void Line(InputOutputArray img, int pt1X, int pt1Y, int pt2X, int pt2Y, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); // // 摘要: // Draws a line segment connecting two points 两点画一个直线 // // 参数: // img: // The image. // // pt1: // First point of the line segment. // // pt2: // Second point of the line segment. // // color: // Line color. // // thickness: // Line thickness. [By default this is 1] // // lineType: // Type of the line. [By default this is LineType.Link8] // // shift: // Number of fractional bits in the point coordinates. [By default this is 0] public static void Line(InputOutputArray img, Point pt1, Point pt2, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); OpenCvSharp.Point pp2 = new OpenCvSharp.Point(20,30); //第1个点 OpenCvSharp.Point pp3; //第2个点 pp3.X = 200; pp3.Y = 200; Scalar pcolor = new Scalar(0,0,225);//RGB Cv2.Line(s2,pp2,pp3,pcolor,1); Cv2.ImShow("线",s2);

    OpenCV的Rect矩形类用法 //如果创建一个Rect对象rect(100, 50, 50, 100),那么rect会有以下几个功能: rect.area(); //返回rect的面积 5000 rect.size(); //返回rect的尺寸 [50 × 100] rect.tl(); //返回rect的左上顶点的坐标 [100, 50] rect.br(); //返回rect的右下顶点的坐标 [150, 150] rect.width(); //返回rect的宽度 50 rect.height(); //返回rect的高度 100 rect.contains(Point(x, y)); //返回布尔变量,判断rect是否包含Point(x, y)点 // // 摘要: // Draws simple, thick or filled rectangle 画一个矩形 // // 参数: // img: // Image. // // rect: // Rectangle. // // color: // Line color (RGB) or brightness (grayscale image). 颜色RGB // // thickness: // Thickness of lines that make up the rectangle. Negative values make the function // to draw a filled rectangle. [By default this is 1] // // lineType: // Type of the line, see cvLine description. [By default this is LineType.Link8] // // shift: // Number of fractional bits in the point coordinates. [By default this is 0] public static void Rectangle(Mat img, Rect rect, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); public static void Rectangle(InputOutputArray img, Point pt1, Point pt2, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); public static void Rectangle(Mat img, Point pt1, Point pt2, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); public static void Rectangle(InputOutputArray img, Rect rect, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0);

    画矩形的实现

    OpenCvSharp.Rect pRect = new OpenCvSharp.Rect(200,200,300,300); Scalar pColor = new Scalar(255,0,0); Cv2.Rectangle(s2,pRect,pColor,2); Cv2.ImShow("矩形",s2);

    图像里画椭圆

    OpenCvSharp实现

    //椭圆 OpenCvSharp.Point pp2 = new OpenCvSharp.Point(s2.Cols / 2, s2.Rows / 2); OpenCvSharp.Size pSize = new OpenCvSharp.Size(s2.Cols / 4, s2.Rows / 8); Scalar pColor = new Scalar(0,0,255); Cv2.Ellipse(s2, pp2, pSize, 90, 0, 360, pColor,1,LineTypes.Link8); //圆形 Cv2.Circle(s2,pp2,100,pColor);

    OpenCvSharp椭圆和圆形的api

    //椭圆 // 摘要: // Draws simple or thick elliptic arc or fills ellipse sector 绘制椭圆 // // 参数: // img: // Image. // // center: // Center of the ellipse. // // axes: // Length of the ellipse axes. // // angle: // Rotation angle. // // startAngle: // Starting angle of the elliptic arc. // // endAngle: // Ending angle of the elliptic arc. // // color: // Ellipse color. // // thickness: // Thickness of the ellipse arc. [By default this is 1] // // lineType: // Type of the ellipse boundary. [By default this is LineType.Link8] // // shift: // Number of fractional bits in the center coordinates and axes' values. [By default // this is 0] public static void Ellipse(InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); public static void Ellipse(InputOutputArray img, RotatedRect box, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8); //Circle // 摘要: // Draws a circle 画圆 // // 参数: // img: // Image where the circle is drawn. // // center: // Center of the circle. // // radius: // Radius of the circle. // // color: // Circle color. // // thickness: // Thickness of the circle outline if positive, otherwise indicates that a filled // circle has to be drawn. [By default this is 1] // // lineType: // Type of the circle boundary. [By default this is LineType.Link8] // // shift: // Number of fractional bits in the center coordinates and radius value. [By default // this is 0] public static void Circle(InputOutputArray img, Point center, int radius, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0); public static void Circle(InputOutputArray img, int centerX, int centerY, int radius, Scalar color, int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0);

    Processed: 0.009, SQL: 8