摄像机之间的角度过大时,OpenCV立体图像校正无法正常工作 [英] OpenCV Stereo Image Rectification doesn't work properly when the angle between cameras is too high

查看:325
本文介绍了摄像机之间的角度过大时,OpenCV立体图像校正无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想收集位于两个摄像机焦点上的物体的高度数据,这就是我的立体声设置:

I want to collect height data about a body sitting at the focus of the two cameras, this is what my stereo set up looks like:

当我使用标准cv2函数计算图像的校正版本时,它看起来非常糟糕.当我对并行摄像机使用类似的设置时,它可以正常工作.

When I calculate the rectified versions of the images using the standard cv2 functions it looks very bad. When I used a similar setup with the cameras in parallel it worked.

我计算了Epiline,它们似乎是正确的:

I calculated the epilines, and they seem to be right:

但是,所得的校正图像不是(下面是原始图像):

However, the resulting rectified images are not (below, the original images are above):

这是我使用的代码,主要是从openCV教程中复制的

This is the code I used, it was mostly copied from an openCV tutorial

http://www.dmi.unict.it/~ furnari/teaching/CV1617/lab1/

3d/2d点和矩阵是先前使用

The 3d/2d points and the matrices were calculated previously using

cv2.calibrateCamera()

校准和纠正过程

retval, _, _, _, _, R, T, E, F = cv2.stereoCalibrate(imager._3d_points, _2d_points_L,_2d_points_R, mtxL, distL, mtxR, distR, (img.shape[1], img.shape[0])

R1, R2, P1, P2, Q, _, _ = cv2.stereoRectify(mtxL, distL, mtxR, distR, (img.shape[1], img.shape[0]), R, T, )

map1_x, map1_y = cv2.initUndistortRectifyMap(imager.mtxL, imager.distL, R1, P1, (imLeft.shape[1], imLeft.shape[0]), cv2.CV_32FC1)
map2_x, map2_y = cv2.initUndistortRectifyMap(imager.mtxR, imager.distR, R2, P2, (imLeft.shape[1], imLeft.shape[0]), cv2.CV_32FC1)

imgL = cv2.remap(imLeft, map1_x, map1_y , cv2.INTER_CUBIC)
imgR = cv2.remap(imRight, map2_x, map2_y , cv2.INTER_CUBIC)

OpenCV只是无法通过相机设置来校正图像还是做错了什么?

Is OpenCV simply not able to rectify images with my camera setup or did I do something wrong?

推荐答案

据我所知,函数stereoRectify假定相机轴彼此大致平行.您可以尝试stereoRectifyUncalibrated,因为此函数依赖基本矩阵计算,并且可以处理这种情况.确保已阅读

As far as I know, the function stereoRectify assumes that the camera axes are approximately parallel to each other. You can try stereoRectifyUncalibrated, as this function relies on fundamental matrix computation and will handle this case. Make sure you've read the note in the documentation.

注意:

虽然算法不需要知道相机的固有参数,但它很大程度上取决于对极几何形状.因此,如果相机镜头有明显的畸变,则最好在计算基本矩阵并调用此函数之前对其进行校正.例如,可以使用calibrateCamera()分别估计立体摄像机每个磁头的失真系数.然后,可以使用undistort()校正图像,或者仅可以使用undistortPoints()校正点坐标.

While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion, it would be better to correct it before computing the fundamental matrix and calling this function. For example, distortion coefficients can be estimated for each head of stereo camera separately by using calibrateCamera(). Then, the images can be corrected using undistort(), or just the point coordinates can be corrected with undistortPoints().

这篇关于摄像机之间的角度过大时,OpenCV立体图像校正无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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