计算关键点的新阵地 [英] Calculating new positions of keypoints

查看:161
本文介绍了计算关键点的新阵地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能有人帮助我,我们怎么能计算转换图像中关键点的新阵地,是在原始图像检测到的关键点。我使用OpenCV的同形矩阵和warpPerspective使转换后的图片。

can somebody help me, how we can calculate the new positions of keypoints in the transformed image,the keypoints were detected in original image. I am using opencv homography matrix and warpPerspective to make the transformed image.

下面是一个code ..

Here is a code..

...
 std::vector< Point2f > 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的新位置。

Now I want to calculate the new positions of points2 in the result1 image.

例如下面的变换的图像中,我们知道的角点。现在我要计算的关键点的新位置改造前说{(X1,Y1),(X2,Y2),(X3,Y3)...},我们该如何计算呢?

For example in the below transformed image , we know the corner points. Now I want to calculate the new position of the keypoints say before transformation {(x1,y1),(x2,y2),(x3,y3)...}, How we can calculate it?

更新:OpenCV的perspectiveTransform做什么,我试图做的。

Update: opencv 'perspectiveTransform' does what I trying to do.

推荐答案

让我们叫 I 通过扭曲图像获得的图像 I 使用单应 ^ h

Let's call I' the image obtained by warping image I using homography H.

如果您提取关键点的 M I =(X I ,Y <子> I ,1)原始图像 I ,就可以得到关键点的 M' I 在扭曲的图像我'使用单应变换:S * M' I = H *的 M I 。注意比例因子S,如果你想在关键点在像素坐标,你的有无的扩展 M' I 这样的第三个因素是1

If you extracted keypoints mi = (xi, yi, 1) in original image I, you can get the keypoints m'i in the warped image I' using the homography transform: S * m'i = H * mi. Notice the scale factor S, if you want the keypoints coordinates in pixels, you have to scale m'i so that the third element is 1.

如果你想了解其中规模因素来自,看看齐次坐标

If you want to understand where the scale factor comes from, have a look at Homogeneous Coordinates.

此外,还有一个OpenCV的功能,这种转变适用于点的数组: perspectiveTransform 文档)。

Also, there is an OpenCV function to apply this transformation to an array of points: perspectiveTransform(documentation).

这篇关于计算关键点的新阵地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆