如何在OpenCV中将平行四边形图像转换为矩形图像

How to transform a parallelogram image to rectangle image in OpenCV?

本文关键字:图像 转换 平行四边形 OpenCV      更新时间:2023-10-16

可能的重复项:
在一组 cv::P oint 上执行 cv::warpPerspective 的假纠偏

我正在使用OpenCV。我想将具有平行四边形的图像转换为矩形图像。请告诉我该怎么做?

谢谢。

查看OpenCV文档中有关仿射变换的信息。那里有例子:

http://opencv.willowgarage.com/documentation/cpp/geometric_image_transformations.html

你想要剪切图像(或图像的一部分)

为此,您可以使用带有warpAffine函数的仿射变换

  void warpAffine(const Mat& src, Mat& dst, const Mat& M, Size dsize, 
                  int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, 
                  const Scalar& borderValue=Scalar())

并阅读此问答:在OpenCV中执行原点改变的剪切