关于C# opencv的WarpPerspective函数的问题

关于C# opencv的WarpPerspective函数的问题

这是我的代码

private void button3_Click(object sender, EventArgs e)
        {
            Mat img = Cv2.ImRead("P1050219.JPG");
            List<Point2f> pts1 = new List<Point2f>();
            pts1.Add(new OpenCvSharp.Point(69, 163));
            pts1.Add(new OpenCvSharp.Point(704, 62));
            pts1.Add(new OpenCvSharp.Point(162, 675));
            pts1.Add(new OpenCvSharp.Point(970, 411));
            IEnumerable<Point2f> pts11 = pts1 as IEnumerable<Point2f>;
            List<Point2f> pts2 = new List<Point2f>();
            pts2.Add(new OpenCvSharp.Point(0, 1000));
            pts2.Add(new OpenCvSharp.Point(0, 0));
            pts2.Add(new OpenCvSharp.Point(750, 1000));
            pts2.Add(new OpenCvSharp.Point(750, 0));
            IEnumerable<Point2f> pts22 = pts1 as IEnumerable<Point2f>;                    
            Mat M = Cv2.GetPerspectiveTransform( pts1, pts2);
            Mat dst = null;
            OpenCvSharp.Size q = new OpenCvSharp.Size(750,1000);
            Cv2.WarpPerspective(img, dst, M, q, InterpolationFlags.Linear, BorderTypes.Constant);
            this.pictureBox.Show();
            this.pictureBox.Image =  dst.ToBitmap();
        }

运行后报错,不知道咋改,求大神解答。
在这里插入图片描述
在这里插入图片描述

发布了2 篇原创文章 · 获赞 0 · 访问量 142

猜你喜欢

转载自blog.csdn.net/qq_35605018/article/details/102770459