【问题标题】:Retrieving the original coordinates of a pixel taken from a warped Image检索从扭曲图像中获取的像素的原始坐标
【发布时间】:2013-01-15 17:33:51
【问题描述】:

我从 sourceImage 中提取了四个角:

src_vertices[0] = corners[upperLeft];
src_vertices[1] = corners[upperRight];   
src_vertices[2] = corners[downLeft];
src_vertices[3] = corners[downRight];

这四个角像这样被扭曲到 destinationImage

dst_vertices[0] = Point(0,0);
dst_vertices[1] = Point(width, 0); 
dst_vertices[2] = Point(0, height);
dst_vertices[3] = Point(width, height);

Mat warpPerspectiveMatrix = getPerspectiveTransform(src_vertices, dst_vertices);
cv::Size size_d =  Size(width, height);
cv::Mat DestinationImage(width,height,CV_8UC3);
warpPerspective(sourceImage, destinationImage, warpPerspectiveMatrix, size_d, INTER_LINEAR, BORDER_CONSTANT);

现在我的问题是:

我有一个取自 destinationImage 的点 p(x,y) 如何在原始 sourceImage 中检索该点的坐标

也就是说我想用warpPerspectiveMatrix做getPerspectiveTransform相反的工作

【问题讨论】:

  • 如果你现在获得一个新的warpPerspectiveMatrix 从目标映射到源,然后将它应用到一个点,你会得到你想要的。这样做有什么问题?

标签: image-processing opencv distortion 3d-reconstruction perspectivecamera


【解决方案1】:

你想要逆透视变换。如果您的原始变换是 S->S',则需要变换矩阵 S'->S

Mat InversewarpPerspectiveMatrix = getPerspectiveTransform(dst_vertices, src_vertices);

然后你做一个稀疏矩阵

Mat PerspectiveCoordinates containing the vector x,y.

终于要打电话了

PerspectiveTransform(PerspectiveCoordinates,OriginalCoordinates,InversewarpPerspectiveMatrix)

【讨论】:

  • SPARSE 矩阵是什么意思!?如何将向量 x,y 添加到 PerspectiveCoordinates!?
  • 这完全是另一个问题。
  • 谢谢Boyko,现在一切都好
  • 我不确定如何添加它们 - 我使用 OpenCV 的 C 功能。我想你已经想通了,很高兴能提供帮助!
  • @Engine try micc.unifi.it/ballan/downloads/ocv_tutorial.pdf 第 23 页“集合和稀疏矩阵”
猜你喜欢
  • 1970-01-01
  • 2022-11-19
  • 2021-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-05
  • 2021-01-27
  • 1970-01-01
相关资源
最近更新 更多