检索从扭曲图像中获取的像素的原始坐标

Zah*_*dar 3 opencv image-processing perspectivecamera distortion 3d-reconstruction

我有一个从sourceImage中提取的四个角:

src_vertices[0] = corners[upperLeft];
src_vertices[1] = corners[upperRight];   
src_vertices[2] = corners[downLeft];
src_vertices[3] = corners[downRight];
Run Code Online (Sandbox Code Playgroud)

这四个角像这样扭曲到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);
Run Code Online (Sandbox Code Playgroud)

现在我的问题是:

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

换句话说,我想使用warpPerspectiveMatrix来完成getPerspectiveTransform的相反工作

Boy*_*nov 6

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

Mat InversewarpPerspectiveMatrix = getPerspectiveTransform(dst_vertices, src_vertices);
Run Code Online (Sandbox Code Playgroud)

然后你制作一个SPARSE矩阵

Mat PerspectiveCoordinates containing the vector x,y.
Run Code Online (Sandbox Code Playgroud)

最后你要打电话

PerspectiveTransform(PerspectiveCoordinates,OriginalCoordinates,InversewarpPerspectiveMatrix)
Run Code Online (Sandbox Code Playgroud)

  • @Engine尝试http://www.micc.unifi.it/ballan/downloads/ocv_tutorial.pdf第23页"集合和稀疏矩阵" (2认同)