计算关键点的新位置

有人可以帮助我,如何计算变换图像中关键点的新位置,在原始图像中检测关键点。 我使用opencv单应矩阵和warpPerspective来制作转换后的图像。

这是一个代码..

... std::vector points1,points2; for( int i = 0; i < matches1.size(); i++ ) { points1.push_back( keypoints_input1[matches1[i].queryIdx ].pt ); points2.push_back( keypoints_input2[matches1[i].trainIdx ].pt ); } /* Find the Homography Matrix for current and next frame*/ Mat H1 = findHomography( points2, points1, CV_RANSAC ); /* Use the Homography Matrix to warp the images*/ cv::Mat result1; warpPerspective(input2, result1, H1, Size(input2.cols+150, input2.rows+150), INTER_CUBIC); ... } 

现在我想计算result1图像中points2的新位置。

例如,在下面的变换图像中 ,我们知道角点。 现在我想计算关键点在变换{(x1,y1),(x2,y2),(x3,y3)…}之前的新位置,我们如何计算它?

更新:opencv’leightingTransform’做我想做的事情。

让我们称之为I'使用单应性H翘曲图像I获得的图像。

如果在原始图像I提取关键点m i =(x i ,y i ,1),则可以使用单应变换获得变形图像I'的关键点m’i:S * m’i = H * m i 。 注意比例因子S,如果你想要以像素为单位的关键点坐标,你必须缩放m’i以便第三个元素是1。

如果您想了解比例因子的来源,请查看同质坐标 。

此外,还有一个OpenCV函数将此转换应用于点数组: perspectiveTransform ( 文档 )。