Emgu Matrix[Double] matrix = new Matrix[Double](height, width)的简单应用

//Matrix<Double> matrix = new Matrix<Double>(height, width);
    private void button1_Click(object sender, EventArgs e)
    {
        //创建一个矩阵
        Matrix<Double> matrix1 = new Matrix<Double>(5, 7);

        double element = 0;
        //设置矩阵元素值
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 7; j++)
            {
                matrix1.Data[i, j] = element;
                element++;
            }
        }
        //显示
        matrixBox1.Matrix = matrix1;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是C# Emgucv绘制旋转矩形的代码: ```csharp using Emgu.CV; using Emgu.CV.Structure; using System.Drawing; // 定义旋转矩形的中心点、宽度、高度和旋转角度 PointF center = new PointF(100, 100); float width = 200; float height = 100; float angle = 45; // 创建一个空白的图像 Image<Bgr, byte> img = new Image<Bgr, byte>(500, 500, new Bgr(255, 255, 255)); // 计算旋转矩形的四个顶点 PointF[] vertices = new PointF[4]; vertices[0] = new PointF(center.X - width / 2, center.Y - height / 2); vertices[1] = new PointF(center.X + width / 2, center.Y - height / 2); vertices[2] = new PointF(center.X + width / 2, center.Y + height / 2); vertices[3] = new PointF(center.X - width / 2, center.Y + height / 2); // 创建旋转矩阵 Matrix<float> rotationMatrix = new Matrix<float>(new float[,] { { (float)Math.Cos(angle * Math.PI / 180), (float)Math.Sin(angle * Math.PI / 180), 0 }, { -(float)Math.Sin(angle * Math.PI / 180), (float)Math.Cos(angle * Math.PI / 180), 0 }, { 0, 0, 1 } }); // 将旋转矩阵应用于顶点 rotationMatrix.TransformPoints(vertices); // 绘制旋转矩形 img.DrawPolyline(vertices, true, new Bgr(0, 0, 255), 2); // 显示图像 CvInvoke.Imshow("Rotated Rectangle", img); CvInvoke.WaitKey(0); ``` 这段代码首先定义了旋转矩形的中心点、宽度、高度和旋转角度,然后创建了一个空白的图像。接着计算旋转矩形的四个顶点,并创建旋转矩阵。最后将旋转矩阵应用于顶点,绘制旋转矩形,并显示图像。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值