Matlab立体相机校准场景重建错误 [英] Matlab Stereo Camera Calibration Scene Reconstruction Error

查看:82
本文介绍了Matlab立体相机校准场景重建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use the Computer Vision System Toolbox to calibrate the pair of cameras below in order to be able to generate a 3-D point cloud of a vehicle at a range between 1 to 5m. The output image size was approximately 1 MB per image for the checkerboard calibration images and the checkerboard square size was 25 mm. The cameras used were a pair of SJ4000 HD1080P cameras. The cameras were placed as parallel to each other as possible with no angle in the vertical axis. The checkboard calibration was done with the aid of a bright light and whiteboard. The mean error per pixel using the stereo camera calibrator code was 3.31 with 31/32 successful pairings. The approximate distance to the checkerboard was 30 cm and the distance between the cameras was 20 cm. The problem I am encountering upon rectification is during the 3D Reconstruction of the scene. The figure below is what was outputted. I’m not sure if there is a parameter that is missing in the camera setup or if there is something that is missing / needs to be added in the script. Below is the code that was used for the Stereo anaglyph and scene reconstruction that was adapted from the Matlab Stereo Camera Calibration tutorial.

% 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学生版.

I have included the images of the Scene Reconstruction, Disparity Map, Mean Error Per Pixel and After Rectification. The version of Matlab I am using is R2014b Student Edition purchased from the Matlab Website.

推荐答案

您在这里有两个问题.正如@ezfn指出的那样,其中之一就是镜头失真可能太严重了.最好尝试在此处拍摄更多的校准图像,以使棋盘格靠近视场的边缘和角落.另外,请尝试将棋盘格放置在距相机不同的距离处.看看是否可以降低这些重新投影的误差.

You have two problems here. One, as @ezfn pointed out, is that the lens distortion may simply be too severe. The best thing to try here is to take even more calibration images so that you have the checkerboard close to the edges and corners of the field of view. Also, try placing the checkerboard at varying distances from the camera. See if you can get those reprojection errors down.

这里的第二个问题是您需要更改 disparity 函数的'DisparityRange'参数.使用 imtool 显示浮雕图像,并使用标尺小工具测量一些成对的对应点之间的距离.那应该使您了解视差范围应该是多少.仅查看图像,我可以看到[0 64]太小了.

The second issue here is that you need to change the 'DisparityRange' parameter of the disparity function. Display the anaglyph image using imtool, and use the ruler widget to measure distances between some pairs of corresponding points. That should give you the idea of what the disparity range should be. Just looking at the image I can see that [0 64] is way too small.

这篇关于Matlab立体相机校准场景重建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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