Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 从扭曲的图像中检索像素的原始坐标_Image Processing_Opencv_Distortion_3d Reconstruction_Perspectivecamera - Fatal编程技术网

Image processing 从扭曲的图像中检索像素的原始坐标

Image processing 从扭曲的图像中检索像素的原始坐标,image-processing,opencv,distortion,3d-reconstruction,perspectivecamera,Image Processing,Opencv,Distortion,3d Reconstruction,Perspectivecamera,我从sourceImage中提取了四个角点: 这四个角扭曲为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(sr

我从sourceImage中提取了四个角点:

这四个角扭曲为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);
现在我的问题是:

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


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

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

Mat InversewarpPerspectiveMatrix = getPerspectiveTransform(dst_vertices, src_vertices);
然后生成一个稀疏矩阵

Mat PerspectiveCoordinates containing the vector x,y.
最后你想打电话吗

PerspectiveTransform(PerspectiveCoordinates,OriginalCoordinates,InversewarpPerspectiveMatrix)

如果您现在获得一个新的
warpPerspectiveMatrix
,将其从目标映射到源,然后将其应用到单个点,您将获得您想要的。这样做有什么问题?你说的稀疏矩阵是什么意思!?如何将向量x,y添加到透视坐标!?这是一个完全不同的问题。谢谢Boyko,现在一切都好了。我不知道如何添加它们-我使用OpenCV的C功能。我想你已经明白了,很高兴能帮上忙@引擎尝试第23页“集合和稀疏矩阵”
PerspectiveTransform(PerspectiveCoordinates,OriginalCoordinates,InversewarpPerspectiveMatrix)