立体校正后如何获得摄像机的投影矩阵? [英] How do I get the projection matrix of a camera after stereo rectification?

查看:440
本文介绍了立体校正后如何获得摄像机的投影矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用calibrateCamera后,我可以从单眼设置中获取投影矩阵.

I'm able to get the projection matrix out of a monocular setup after using calibrateCamera.

此stackoverflow答案解释方法.

现在,我按照立体声校准样本进行操作,在对立体声进行校正后,我想对两台相机都做同样的操作(

Now, I follow the stereo calibration sample and I would like to do the same for both cameras after I do stereo rectification (openCV - stereo rectify). The method gives me Q, R1, R2, P1 and P2 matrices.

void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags=CALIB_ZERO_DISPARITY, double alpha=-1, Size newImageSize=Size(), Rect* validPixROI1=0, Rect* validPixROI2=0 )

我假设我必须以某种方式将它们组合在一起,但是我不明白如何将这些输出矩阵与相机的本征和非本征联系起来.

I assume I have to combine them somehow, but I don't understand how to relate these output matrices to intrinsics and extrinsics of a camera.

提前谢谢!

假设我的相机没有失真.我知道我可以使用initUndistorRectifyMap重新映射图像并重新映射.但是,我只是想通过使用投影矩阵来编写一些自己的代码,即如果只是一次相机校准,我将获得相机矩阵C,以及旋转和平移矢量,将它们组合到投影矩阵中由C * [R | t].我想做同样的事情,但要调整摄像机的位置.

Let's assume my cameras don't have distortion. I understand I can get remap the images using initUndistorRectifyMap and remap. But, I'm just interested in writing some of my own code by using the projection matrix, i.e. if it's just a single camera calibration, I get the camera matrix C, and the rotation and translation vector, I combine them to the projection matrix by C * [R |t]. I'd like to do the same but for the rectified camera position.

推荐答案

这里的答案是显而易见的,尽管当时并非如此.我要寻找的投影矩阵是P1和P2.我想知道如何使用失真参数构造它们.实际上,这不是必需的,因为整个重新映射过程不会使图像失真,因此我们可以立即使用P1和P2作为投影.希望这对某人有帮助.

The answer here is somewhat obvious, although it wasn't so at the time. The projection matrices I'm looking for was P1 and P2. I was wondering how to construct them with distortion parameters. Actually, this is not necessary, because the whole remap process undistorts the images, so that we can straight away make use P1 and P2 as the projection. Hope this helps someone.

这篇关于立体校正后如何获得摄像机的投影矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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