[英]What is the difference between warpPerspective and perspectiveTransform?
I have used four sets of points to get a perspective transform matrix.我使用了四组点来获得透视变换矩阵。 Then using warpPerspective
to transform the matrix A
to matrix B
.然后使用warpPerspective
将矩阵A
转换为矩阵B
。 Point a from Mat A. I want to get the new point a position in mat B. But warpPerspective
cannot do that, while perspectiveTransform
can.来自垫 A 的点 a。我想在垫 B 中获得新点的位置。但warpPerspective
不能这样做,而perspectiveTransform
warpPerspective
可以。
Here I want to know if the position that perspectiveTransform
gets is the same as the position in matrix B by using warpPerspective
.这里我想通过使用warpPerspective
来知道perspectiveTransform
变换得到的位置是否与矩阵 B 中的位置相同。
So, what is the difference between warpPerspective
and perspectiveTransform
?那么, warpPerspective
和perspectiveTransform
之间有什么区别?
Mat trans = getPerspectiveTransform(dst, gpsPoints);
warpPerspective(A, B, trans, image.size());
Point2f a = Point2f(..., ...); //were known
vector<Point2f> obj(1);
obj[0] = a;
vector<Point2f> b;
perspectiveTransform(obj, b, trans);//if the new point in B is c, is c equals to b?
warpPerspective
works for images. warpPerspective
适用于图像。 In other words, warpPerspective can warp image A and put the result in B using the H (Homography or warpMatrix) so it has the following struct:换句话说,warpPerspective 可以使用 H(Homography 或 warpMatrix)扭曲图像 A 并将结果放在 B 中,因此它具有以下结构:
void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
src
is the Mat
you want to warp, dst
where the result will be stored. src
是您要扭曲的Mat
, dst
是结果将存储的位置。
perspectiveTransform
works for set of points. perspectiveTransform
适用于一组点。 It applies the H (Homography or warpMatrix) on set of points (which are in vector
for example) and put the results in another vector
.它将 H(Homography 或 warpMatrix)应用于一组点(例如在vector
中)并将结果放入另一个vector
。 The results are the points in the first vector
after applying the warping.结果是应用变形后第一个vector
中的点。 it has the following struct:它具有以下结构:
void perspectiveTransform(InputArray src, OutputArray dst, InputArray m)
where src
is the input points, dst
is the results of warping the input points.其中src
是输入点, dst
是扭曲输入点的结果。
Conclusion :结论:
Mathematically , they both do the same thing which is warping a set of point using H.从数学上讲,它们都做同样的事情,即使用 H 扭曲一组点。
Technically , warpPerspective
do this on the coordinates of the Mat
and move the pixel value(color) to a new pixel.从技术上讲, warpPerspective
在Mat
的坐标上执行此操作并将像素值(颜色)移动到新像素。 perspectiveTransform
, it just compute the new coordinate of the point and store it in the new vector
. perspectiveTransform
vector
,它只是计算点的新坐标并将其存储在新vector
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.