opencvsharp Cv2.GetRotationMatrix2D().Transform()实例
时间: 2023-05-27 16:01:47 浏览: 192
以下是使用OpencvSharp中Cv2.GetRotationMatrix2D().Transform()方法的示例:
```
using OpenCvSharp;
namespace OpencvSharpDemo
{
class Program
{
static void Main(string[] args)
{
Mat src = new Mat("test.jpg", ImreadModes.Color);
Mat dst = new Mat();
Point2f center = new Point2f(src.Width / 2f, src.Height / 2f);
Mat rotMat = Cv2.GetRotationMatrix2D(center, 45, 1); // 顺时针旋转45度,放缩因子为1
Cv2.WarpAffine(src, dst, rotMat, src.Size()); // 对图像进行仿射变换
Cv2.ImShow("src", src); // 显示原图
Cv2.ImShow("dst", dst); // 显示旋转后的图像
Cv2.WaitKey(0); // 等待按键
}
}
}
```
该示例加载名为"test.jpg"的图像,以其中心为旋转中心,将图像顺时针旋转45度,然后将旋转后的图像显示在屏幕上。其中Cv2.GetRotationMatrix2D()方法用于创建旋转的仿射变换矩阵,Cv2.WarpAffine()方法用于将图像应用仿射变换。
阅读全文
相关推荐














