需要帮助确定立体相机校准的质量和设置校准矩阵

时间:2017-01-15 09:41:26

标签: matlab computer-vision

我正在玩两个便宜的网络摄像头(0.3Mpx),尝试制作可以测量物体距离和尺寸的立体摄像机。但我很难找到如果我的立体相机校准正确完成以及如何继续设置相机校准矩阵?

到目前为止我所做的是制作相机装置,将相机设置为相距30厘米,稍微向内倾斜,使图像或多或少相互重叠。我把Matlab的校准棋盘(A4尺寸)放在离相机大约50厘米处。然后我开始通过我制作的Matlab脚本在不同的角度和位置拍摄20个图像对,并将它们馈送到Matlab中的立体相机校准应用程序。这是我得到的结果:

外部参数可视化 - 这是让我觉得我的校准出现问题的图像,因为看起来相机并没有分开:

Img1

像素均值错误重现 - 这里我删除了一些具有更高责任错误的图像对:

Img2

Standard Errors of Estimated Stereo Camera Parameters ----------------------

Camera 1 Intrinsics ------------------- 
Focal length (pixels): [ 829.8567 +/- 4.6262 831.1900 +/- 4.4714 ] 
Principal point (pixels):[ 437.7113 +/- 1.8180 254.0188 +/- 1.9227 ] 
Skew: [ 1.7063 +/- 0.3069 ] 
Radial distortion: [ 0.0024 +/- 0.0067 -0.1042 +/- 0.0281 ] 
Tangential distortion: [ 0.0036 +/- 0.0006 0.0100 +/- 0.0007 ]

Camera 1 Extrinsics ------------------- 
Rotation vectors: 
[ -0.0289 +/- 0.0020 0.1813 +/- 0.0025 -0.0132 +/- 0.0005 ] [ -0.2268 +/- 0.0030 -0.3439 +/- 0.0026 -0.1029 +/- 0.0004 ] [ -0.0209 +/- 0.0024 -0.0018 +/- 0.0024 -0.0438 +/- 0.0003 ] [ 0.0962 +/- 0.0032 -0.2916 +/- 0.0034 -1.8484 +/- 0.0004 ] [ -0.0042 +/- 0.0021 0.1804 +/- 0.0027 -0.0219 +/- 0.0006 ] [ -0.2726 +/- 0.0039 0.1822 +/- 0.0041 2.8569 +/- 0.0007 ] [ 0.0499 +/- 0.0020 0.1646 +/- 0.0024 -0.0207 +/- 0.0004 ] [ -0.2745 +/- 0.0024 0.0080 +/- 0.0022 -1.5557 +/- 0.0004 ] [ -0.2607 +/- 0.0024 0.0325 +/- 0.0022 -1.5807 +/- 0.0004 ] [ -0.2684 +/- 0.0028 0.0384 +/- 0.0025 -1.5800 +/- 0.0006 ]

Translation vectors (mm): 
[ -150.5696 +/- 1.0617 -46.2962 +/- 1.1548 491.0520 +/- 2.7303 ] [ -214.8622 +/- 1.1726 -40.0423 +/- 1.2625 528.0044 +/- 2.9924 ] [ -164.9147 +/- 1.0168 -69.9880 +/- 1.1023 465.4540 +/- 2.6645 ] [ -37.2595 +/- 1.4144 59.4185 +/- 1.4939 643.6316 +/- 3.5056 ] [ -203.2476 +/- 1.0742 -42.6796 +/- 1.1813 493.9661 +/- 2.7924 ] [ 109.4280 +/- 1.4785 -69.4211 +/- 1.5662 678.8234 +/- 3.6783 ] [ -130.7829 +/- 1.0151 -42.2859 +/- 1.1012 468.7133 +/- 2.6260 ] [ -73.5988 +/- 1.0368 64.6519 +/- 1.1120 473.5281 +/- 2.6423 ] [ -43.1916 +/- 1.0432 73.5025 +/- 1.1112 474.7453 +/- 2.6190 ] [ -204.2203 +/- 1.1513 64.6115 +/- 1.2599 524.6072 +/- 3.0409 ]

Camera 2 Intrinsics ------------------- 
Focal length (pixels): [ 829.8567 +/- 4.6262 831.1901 +/- 4.4714 ] 
Principal point (pixels):[ 437.7113 +/- 1.8180 254.0188 +/- 1.9227 ] 
Skew: [ 1.7063 +/- 0.3069 ] 
Radial distortion: [ 0.0024 +/- 0.0067 -0.1042 +/- 0.0281 ] 
Tangential distortion: [ 0.0036 +/- 0.0006 0.0100 +/- 0.0007 ]

Position And Orientation of Camera 2 Relative to Camera 1 ----------------------Rotation of camera 2: [ 0.0000 +/- NaN 0.0000 +/- NaN 0.0000 +/- NaN ] Translation of camera 2 (mm): [ -0.0000 +/- 0.0696 -0.0000 +/- 0.0759 0.0000 +/- 0.4605 ]

如果有人能够帮助我进一步了解这个项目,那将非常感激:-)已经把我的头靠在墙上一段时间了

1 个答案:

答案 0 :(得分:0)

为了检查摄像机校准的准确性,您可以重建位于立体摄像机视野内不同位置的物体的两个点之间的已知距离,并查看结果是否正确。

如果您已使用Matlab Stereo Camera Calibrator应用程序并将结果保存为mat文件,则可以使用以下脚本计算两点之间的欧几里德距离并与已知几何进行比较。< / p>

%Pick two points in the Left Image
cam1 = uigetfile('*', 'Select Left Image');
imshow(cam1)
[x y] = ginput(2);% 2 is the number of points
x_left_image = vertcat(x',y');
close all

%Pick the same two points in the Right Image
cam2 = uigetfile('*', 'Select Right Image');
imshow(cam2)
[x y] = ginput(2);% 2 is the number of points
x_right_image = vertcat(x',y');
close all


load calibrationSession.mat %load the stereo calibration data .mat
[Xc_1_left, error] = triangulate(x_left_image',x_right_image',calibrationSession.CameraParameters);

Xc_1_left = Xc_1_left';

X = cell(size(Xc_1_left,2),1);
Y = cell(size(Xc_1_left,2),1);
Z = cell(size(Xc_1_left,2),1);

for n = 1:size(Xc_1_left,2);

    X{n,1} = Xc_1_left(1,n);
    Y{n,1} = Xc_1_left(2,n);
    Z{n,1} = Xc_1_left(3,n);

end

distance = cell(size(Xc_1_left,2)-1,1);

for i = 1:size(Xc_1_left,2)-1;

    distance{i,1} = sqrt((X{i+1} - X{i})^2 + (Y{i+1} - Y{i})^2 + (Z{i+1} -Z{i})^2)

end 

P.S。请记住将校准数据(.mat)和两个图像都放在当前文件夹中。