public override void Process(ref Image <Bgr, byte> image) { // the un-warped perspective var src = new[] { new PointF(0, 0), new PointF(image.Width, 0), new PointF(image.Width, image.Height), new PointF(0, image.Height) }; // the warped perspective var dst = new[] { new PointF(_p1X, _p1Y), new PointF(_p2X, _p2Y), new PointF(_p3X, _p3Y), new PointF(_p4X, _p4Y) }; // get the perspective transformation matrix using (var mat = CvInvoke.GetPerspectiveTransform(src, dst)) { // apply the matrix CvInvoke.WarpPerspective( image, image, mat, new Size(_width, _height), _interpolationType, _warpType, (BorderType)_borderType, new Bgr(_backgroundColor.Color()).MCvScalar); } }
public override void Process(ref Image <Bgr, byte> image) { // the source perspective var src = new[] { new PointF(0, 0), new PointF(image.Width, 0), new PointF(0, image.Height) }; // the transformed perspective var dst = new[] { new PointF(_p1X, _p1Y), new PointF(_p2X, _p2Y), new PointF(_p3X, _p3Y) }; // get the perspective transformation matrix using (var mat = CvInvoke.GetAffineTransform(src, dst)) { // apply the matrix image = image.WarpAffine( mat, _width, _height, _interpolationType, _warpType, (BorderType)_borderType, new Bgr(_backgroundColor.Color())); } }