给定第一个相机姿势的校准立体装置的第二个相机的姿势估计 [英] Pose estimation of 2nd camera of a calibrated stereo rig, given 1st camera pose

查看:24
本文介绍了给定第一个相机姿势的校准立体装置的第二个相机的姿势估计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 opencv 校准了一对立体相机.这会导致两个摄像头之间发生旋转和平移.

Using opencv I've calibrated a pair of cameras in stereo. This results in a Rotation and Translation between the two cameras.

我使用第一个摄像头(左)拍摄图像并使用 solvePnp 计算左摄像头相对于零件的姿态(rvec 和 tvec).

I take an image using the 1st camera (left) and use solvePnp to calculate the pose (rvec and tvec) of the left camera relative to a part.

我的问题是如何使用左相机的姿势以及给定的 R & 计算右相机的姿势.来自立体校准的 T 值?

My question is how to I calculate the pose of the right camera using the pose of the left camera, and the given R & T values from the stereo calibration?

谢谢.

推荐答案

这个问题有点不清楚,但我认为你想找到合适的相机相对于部分.如果是这种情况,最简单的方法如下:

The question is a bit unclear, but I think that you would like to find the pose of the right camera with respect to the part. If this is the case, the easiest way to proceed is as follows:

  • 令 Q_pl 为左相机相对于零件的姿势.这由一个 4x4 矩阵表示,其前 3 行和 3 列是零件 w.r.t.的旋转矩阵 R_pl.左相机(你的 rvec),底行是 [0, 0, 0, 1],第 4 列的前 3 行是平移向量 t_pl from 相机 部分(您的 tvec).为了澄清起见,您通过将零件的 x、y 和 z 轴单位向量(从相机中看到的)的相机帧中的纵坐标分量写为列向量,然后是向量 from相机部分,然后第四行写[0, 0, 0, 1].
  • 同样,让 Q_lr 是左侧相机相对于右侧相机的姿势(从校准中获得).您编写这个 4x4 矩阵,将左摄像机的 x、y、z 单位向量的分量(从右摄像机看)作为列向量,然后是平移向量来自右侧摄像机 左边,然后第四行写[0, 0, 0 1].
  • 零件的姿势 w.r.t.那么正确的相机就是两个矩阵的乘积:

  • Let Q_pl be the pose of the left camera with respect to the part. This is represented by a 4x4 matrix whose first 3 rows and columns are the rotation matrix R_pl of the part w.r.t. the left camera (your rvec), the bottom row is [0, 0, 0, 1], and top 3 rows of of the 4 column are the component of the translation vector t_pl from the camera to the part (your tvec). To clarify, you write Q_pl by writing, ordinately, the component in camera frame of the x, y and z axis unit vectors of the part (as seen from the camera) as column vectors, followed by the vector from the camera to the part, and then write [0, 0, 0, 1] as the fourth row.
  • Likewise, let Q_lr be the pose (obtained from the calibration) of the left camera with respect to the right one. You write this 4x4 matrix laying the components of the x, y, z unit vectors of the left camera (as see from the right one) as column vectors, followed by the translation vector from the right camera to the left one, and then write [0, 0, 0 1] as the fourth row.
  • The pose of the part w.r.t. the right camera is then simply the product of the two matrices:

Q_pr = Q_pl * Q_lr

Q_pr = Q_pl * Q_lr

请注意,因子的顺序很重要.这个表达式简单地说,要从右相机转到零件,您可以先从右相机转到左相机,然后再从那里转到零件.同样,这个变换的旋转部分在 Q_pr 的前 3 行 3 列,从右相机到该部分的平移向量在第 4 列.

Note that the order of the factors matters. This expression simply says that to go from the right camera to the part, you can first go from the right camera to the left one, and then from there to the part. Again, the rotation part of this transformation is in the top 3 rows and 3 columns of Q_pr, and the translation vector from the right camera to the part is in the 4th column.

请注意,您的校准程序可能给您的是 Q_rl,而不是 Q_lr.如果是这种情况,您只需将其反转即可.逆很容易计算:

Note that your calibration procedure may have given you Q_rl, rather than Q_lr. If this is the case, you just invert it. The inverse is very easy to compute:

R_lr = transpose(R_rl)
t_lr = -(R_lr * t_rl)

同样,如果这是您的 solvePnP 生成的,您将反转 Q_lp,而不是 Q_pl.

Likewise, you'll invert Q_lp if that's what your solvePnP produced, rather than Q_pl.

这篇关于给定第一个相机姿势的校准立体装置的第二个相机的姿势估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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