Matlab立体摄像机校准场景重建误差

时间:2015-08-15 15:44:36

标签: matlab camera camera-calibration matlab-cvst 3d-reconstruction

我正在尝试使用计算机视觉系统工具箱来校准下面的一对相机,以便能够在1到5米的范围内生成车辆的三维点云。对于棋盘校准图像,输出图像尺寸大约为每个图像1MB,棋盘方形尺寸为25mm。使用的相机是一对SJ4000 HD1080P相机。相机尽可能彼此平行放置,垂直轴没有角度。借助于强光和白板完成检查板校准。使用立体相机校准器代码的每像素平均误差为3.31,成功配对31/32。到棋盘的大概距离是30厘米,相机之间的距离是20厘米。 enter image description here 我在整改时遇到的问题是在场景的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学生版。

Scene Reconstruction

Mean Error per Pixel

After Rectification

Disparity Map

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

这里有两个问题。正如@ezfn指出的那样,一个是镜头失真可能过于严重。在这里尝试的最好的事情是采取更多的校准图像,以便让棋盘靠近视野的边缘和角落。另外,尝试将棋盘放置在离相机不同的距离处。看看你是否可以减少这些重投影错误。

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