1. Mat mat = new Mat(@"I:\OpenCvSharp学习\Temp\Test\1.bmp", ImreadModes.AnyColor);
    2. int width = mat.Width;
    3. int heigth = mat.Height;
    4. Point point1 = new Point(width / 2, heigth / 2);
    5. Window window1 = new Window("源图像", WindowMode.Normal, mat);
    6. Cv2.Rectangle(mat,new Rect(20,20,60,40),Scalar.Red);
    7. Window window2 = new Window("处理1", WindowMode.Normal, mat);
    8. Cv2.WaitKey(0);

    image.png

    1. //参数说明:
    2. //重载一:
    3. public static void Rectangle(InputOutputArray img,
    4. Rect rect,
    5. Scalar color,
    6. int thickness = 1,
    7. LineTypes lineType = LineTypes.Link8,
    8. int shift = 0);
    9. //rect:需要绘制的矩形
    10. //举例:
    11. Cv2.Rectangle(mat,new Rect(20,20,60,40),Scalar.Red);
    12. //thickness 为负数时,填充该矩形,默认为-1;

    image.png