opencv中reprojectImageTo3D函数的Q矩阵 [英] Q matrix for the reprojectImageTo3D function in opencv
问题描述
我正在opencv中进行一个项目,以使用立体声校准来检测盲人路径中的障碍物.我已经正确计算了视差图.现在要找到障碍物到相机的距离,我希望它的3D坐标[X,Y,Z]可以通过reprojectImageTo3D()找到,但我没有在此函数中使用的Q矩阵,因为我从stereoRectify()获取的Q矩阵可能为空,这可能是因为我使用了预先校准的图像.虽然我确实有相机的固有参数和外在参数. 因此,我的问题是,如果我知道焦距,基线以及有关相机的所有其他信息,该如何手动创建Q矩阵以直接在reprojectImageTo3D()函数中使用? Q矩阵的基本格式是什么?
I am doing a project in opencv to detect obstacle in the path of a blind person using stereo calibration. I have calculated the disparity map correctly. Now to find the distance of obstacle from the camera, I want its 3D coordinates [X,Y,Z] , which I am guessing can be found by reprojectImageTo3D(), but I dont have the Q matrix to use in this function because the Q matrix I am getting from stereoRectify() is coming null probably because I used pre calibrated images. Although I do have the inrinsic and extrinsic parameters of my camera. So my question is that how can I manually create the Q matrix to directly use in the function reprojectImageTo3D(), if I know the focal length, baseline and everything else about my camera? What is the basic format of the Q matrix?
推荐答案
Q矩阵的形式如下:
在该图像中, c x 和 c y 是左侧主点的坐标摄像头(如果您使用左摄像头主导进行了立体匹配), c' x 是右摄像头( c <如果您为stereoRectify()
,指定CV_CALIB_ZERO_DISPARITY
标志,则sub> x 和 c' x 相同f 是焦距, T x 是基线长度(可能是基线长度的负数,是从一个光学中心到另一个光学中心的平移想).
In that image, cx and cy are the coordinates of the principal point in the left camera (if you did stereo matching with the left camera dominant), c'x is the x-coordinate of the principal point in the right camera (cx and c'x will be the same if you specified the CV_CALIB_ZERO_DISPARITY
flag for stereoRectify()
), f is the focal length and Tx is the baseline length (possibly the negative of the baseline length, it's the translation from one optical centre to the other I think).
我建议您看一本书 学习OpenCV 了解更多信息.它仍然基于较旧的C接口,但是在解释基础理论方面做得很好,也是我从中获得Q矩阵形式的地方.
I would suggest having a look at the book Learning OpenCV for more information. It's still based on the older C interface, but does a good job of explaining the underlying theory, and is where I sourced the form of the Q matrix from.
这篇关于opencv中reprojectImageTo3D函数的Q矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!