【问题标题】:Need help to determine quality of stereo camera calibration and setting up calibration matrix需要帮助确定立体相机校准的质量和设置校准矩阵
【发布时间】:2017-01-15 09:41:25
【问题描述】:

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

到目前为止,我所做的是制作一个相机装置,其中相机相距 30 厘米,略微向内倾斜,因此图像或多或少地相互重叠。我将 Matlab 中的校准棋盘(A4 尺寸)放在离相机约 50 厘米的地方。然后我继续通过我制作的 Matlab 脚本以不同的角度和位置拍摄 20 对图像,并将它们提供给 Matlab 中的立体相机校准应用程序。这是我得到的结果:

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

像素均值错误重投影 - 这里我删除了一些重投影错误较高的图像对:

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 ]

如果有人能够帮助我在这个项目上走得更远,将不胜感激 :-) 已经把我的头撞到墙上一段时间了

【问题讨论】:

  • 奇怪的是棋盘平面看起来都是平行的。在拍摄 20 张图像时,您是否将其倾斜了各种角度?
  • 我做到了,但尝试将其保持在 matlab 教程中指定的小于 45 度的角度。但是带有倾斜的图像通常会得到非常高的重投影误差,并且按照 matlab 指南,我已将它们从校准集中删除。现在已经尝试了很多次,即使有更多角度的图片也没有任何成功。是否有可能是廉价的光学元件或相机的低分辨率(VGA - 640x480)导致校准非常困难?
  • 你认为Extrinsics可视化结果有效吗?当我查看旋转向量值时,它们在 x 和 y 分量中存在一些差异,但在可视化中,它们仅沿 z 轴旋转。我认为在这个阶段,小于 1 像素的平均重投影误差是可以的。校准算法需要将平面旋转至少 3 个(或更多)不同的角度。
  • 我还在学习阶段,所以我不知道结果是否有效。这就是我要学习的内容,希望有经验的人可以尝试向我展示如何理解结果

标签: matlab computer-vision


【解决方案1】:

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

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

%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 

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-07
    • 2020-10-16
    • 2013-10-07
    • 2011-05-13
    • 2014-07-30
    • 2018-10-12
    • 2015-03-16
    • 2018-12-15
    相关资源
    最近更新 更多