Matlab立体相机校准场景重建错误

Matlab Stereo Camera Calibration Scene Reconstruction Error

我正在尝试使用计算机视觉系统工具箱来校准下面的一对摄像头,以便能够生成 1 到 5 米范围内的车辆的 3-D 点云。棋盘校准图像的输出图像大小约为每幅图像 1 MB,棋盘正方形大小为 25 毫米。使用的摄像机是一对 SJ4000 HD1080P 摄像机。相机尽可能相互平行放置,垂直轴上没有角度。棋盘校准是在强光和白板的帮助下完成的。使用立体相机校准器代码的每像素平均误差为 3.31,配对成功率为 31/32。到棋盘的大约距离为 30 厘米,相机之间的距离为 20 厘米。 我在整改时遇到的问题是在场景的 3D 重建期间。下图是输出的。我不确定相机设置中是否缺少参数,或者脚本中是否缺少/需要添加某些参数。下面是用于立体立体图像和场景重建的代码,改编自 Matlab 立体相机校准教程。

% Read in the stereo pair of images.
I1 = imread('left.jpg');
I2 = imread('right.jpg');

% Rectify the images.
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams);

% Display the images before rectification.
figure;
imshow(stereoAnaglyph(I1, I2), 'InitialMagnification', 50);
title('Before Rectification');

% Display the images after rectification.
figure;
imshow(stereoAnaglyph(J1, J2), 'InitialMagnification', 50);
title('After Rectification');
% 
% Compute Disparity for 3-D Reconstruction 
% The distance in pixels between corresponding points in the rectified images is called disparity. 
% The disparity is used for 3-D reconstruction, because it is proportional to the distance between the cameras and the 3-D world point.
disparityMap = disparity(rgb2gray(J1), rgb2gray(J2));
figure;
imshow(disparityMap, [0, 64], 'InitialMagnification', 50);
colormap('jet');
colorbar;
title('Disparity Map');

%Reconstruct the 3-D Scene
%Reconstruct the 3-D world coordinates of points corresponding to each pixel     from the disparity map.

point3D = reconstructScene(disparityMap, stereoParams);

% Convert from millimeters to meters.
point3D = point3D / 1000;

% Visualize the 3-D Scene
% Plot points between 3 and 7 meters away from the camera.
z = point3D(:, :, 3);
zdisp = z;
point3Ddisp = point3D;
point3Ddisp(:,:,3) = zdisp;
showPointCloud(point3Ddisp, J1, 'VerticalAxis', 'Y',...
    'VerticalAxisDir', 'Down' );
xlabel('X');
ylabel('Y');
zlabel('Z');

我已经包含了场景重建、视差图、每像素平均误差和校正后的图像。我使用的Matlab版本是从Matlab官网购买的R2014b学生版

  • 我认为这里最明显的问题是重投影 您在立体校准中得到的错误(超过 3 个像素),点 校准问题。我建议您重新校准以获得 较小的重新投影误差(应明显低于 1 个像素 以获得良好的重建结果)。
  • 关于您的校准的另一个问题:什么是镜头畸变 你用的型号?我相信你那里有鱼眼镜头 - 我 我不确定 Matlab 工具箱是否知道如何处理这些。

你这里有两个问题。其一,正如@ezfn 指出的那样,镜头畸变可能太严重了。此处最好尝试的方法是拍摄更多校准图像,使棋盘靠近视野的边缘和角落。此外,尝试将棋盘放置在距相机不同距离的位置。看看您是否可以降低这些重投影误差。

这里的第二个问题是您需要更改 disparity 函数的 'DisparityRange' 参数。使用 imtool 显示立体图像,并使用标尺小部件测量一些对应点对之间的距离。这应该让您了解视差范围应该是多少。只看图片我可以看到 [0 64] 太小了。