OpenCV中的recoverPose()函数是否是惯用左手的? [英] Is the recoverPose() function in OpenCV is left-handed?

查看:1035
本文介绍了OpenCV中的recoverPose()函数是否是惯用左手的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对OpenCV相机姿态估计进行了简单的测试.将照片和同一张照片放大(放大)后,我用它们来检测特征,计算基本矩阵并恢复相机的姿势.

I run simple test for OpenCV camera pose estimation. Having a photo and the same photo scaled up (zoomed in) I use them to detect features, calculate essential matrix and recover camera poses.

Mat inliers;
Mat E = findEssentialMat(queryPoints, trainPoints, cameraMatrix1, cameraMatrix2,
                         FM_RANSAC, 0.9, MAX_PIXEL_OFFSET, inliers);

size_t inliersCount =
    recoverPose(E, queryGoodPoints, trainGoodPoints, cameraMatrix1, cameraMatrix2, R, T, inliers);

因此,当我将原始图像指定为第一张图像并将缩放图像指定为第二张图像时,我得到的平移T接近[0; 0; -1].但是,第二个摄像头(变焦)实际上比第一个更靠近物体.因此,如果Z轴从图像平面进入场景,则第二台摄像机应沿Z轴具有正偏移.对于我得到的结果,Z轴从图像平面朝向相机,该轴与其他轴(X朝右,Y朝下)形成左手坐标系.真的吗?为什么此结果与此处所示的坐标系不同?

So when I specify the original image as the first one, and the zoomed image as the second one, I get translation T close to [0; 0; -1]. However the second camera (zoomed) is virtually closer to the object than the first one. So if Z-axis goes from image plane into the scene, the second camera should have positive offset along Z-axis. For the result I get, Z-axis goes from the image plane towards camera, which among with other axes (X goes right, Y goes down) forms left-handed coordinate system. Is that true? Why this result differs from the coordinate system illustrated here?

推荐答案

根据OpenCV 文档,recoverPose函数中的算法基于论文Nistér,D.五点相对姿势问题的有效解决方案CVPR 2003".根据本文第2节中的方程式,我们知道它使用了基本的三角形关系(请参见图此处):

According to the OpenCV document, the algorithm in the function recoverPose is based on the paper "Nistér, D. An efficient solution to the five-point relative pose problem, CVPR 2003." From equations in Section 2 in this paper, we know it uses the basic triangle relationship (see figure here):

x2 = R * x1 + t

x2 = R*x1 + t

因此,平移t是cam2帧中从cam2到cam1的向量.这就解释了为什么您得到的答案t接近[0; 0; -1].

Therefore, translation t is the vector from cam2 to cam1 in cam2 frame. This explains why you get the answer t close to [0; 0; -1].

这篇关于OpenCV中的recoverPose()函数是否是惯用左手的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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