首页 文章

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

提问于
浏览
4

我正在尝试使用计算机视觉系统工具箱来校准下面的一对相机,以便能够在1到5米的范围内生成车辆的三维点 Cloud . 对于棋盘校准图像,输出图像尺寸大约为每个图像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 回答

  • 1

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

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

  • 2
    • 我认为这里最明显的问题是你在立体声校准中得到的重新投影误差(超过3个像素)指向校准问题 . 我建议你重新校准以获得较小的重新投影误差(对于良好的重建结果,应该明显低于1个像素) .

    • 关于校准的另一个问题:你使用什么镜片失真模型?我相信你有鱼眼镜头 - 我不确定Matlab工具箱知道如何处理这些 .

相关问题