目录 一 安装二 bitmap和mat转换三 透视变换 一 安装 二 bitmap和mat转换 //(1)转为 bitmap: Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat); process_pictureBox.Image = map; //(2)Image img 转为Mat Bitmap bitmap = new Bitmap(img);//Image img OpenCvSharp.Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);//用bitmap转换为mat 三 透视变换 /*以下代码只展示变换部分,其中ImageIn为输入图像,ImageOut为输出图像*/ //变换前的四点 var srcPoints = new Point2f[] { new Point2f(5, 648), new Point2f(751, 643), new Point2f(184, 280), new Point2f(589, 272), }; //变换后的四点 var dstPoints = new Point2f[] { new Point2f(0, 703), new Point2f(524, 703), new Point2f(0, 0), new Point2f(524, 0), }; //根据变换前后四个点坐标,获取变换矩阵 Mat mm = Cv2.GetPerspectiveTransform(srcPoints, dstPoints); //进行透视变换 Cv2.WarpPerspective(ImageIn, ImageOut, mm, GrayImage.Size());