借助Matlab标定
在MATLAB的APP中找到
Stereo Camrea Calibrator
,打开。点击Add Images,选择双目照片,camera1和camera2的存放路径必须分开。每个棋盘格的长度是25mm(我是采用的OpenCV官方的标定图纸,9*6,每个格子是标准的25mm)
点击确定,导入图像成功后,点击
Calibrate
,开始标定。标定结束后点击Show Rectified
可以显示矫正图。成功生成矫正图,但是我们发现有一组差距明显过大,可以在柱状图的长条上面选中误差最大的一组,按delete键删除,将自动重新生成新的矫正参数和矫正图。
可以选择
Export Camera Parameters
到出双目参数或MATLAB标定脚本,单独运行标定脚本会得到如下的标定结果输出:
Matlab标定结果
Standard Errors of Estimated Stereo Camera Parameters
-----------------------------------------------------
Camera 1 Intrinsics //相机1内参
-------------------
Focal length (pixels): [ 452.8131 +/- 3.8144 452.8235 +/- 3.8139 ]
Principal point (pixels):[ 303.0163 +/- 1.0834 228.0770 +/- 0.6888 ]
Radial distortion: [ -0.0241 +/- 0.0168 0.4826 +/- 0.1491 ]
Camera 1 Extrinsics //相机1外参
-------------------
Rotation vectors: //外参旋转矩阵
[ -0.0851 +/- 0.0021 -0.2526 +/- 0.0028 1.2113 +/- 0.0004 ]
[ -0.0063 +/- 0.0039 -0.2043 +/- 0.0036 -0.4643 +/- 0.0005 ]
[ 0.1201 +/- 0.0033 -0.2520 +/- 0.0033 -0.7513 +/- 0.0006 ]
[ 0.2224 +/- 0.0035 -0.2507 +/- 0.0032 -1.5631 +/- 0.0006 ]
[ 0.4167 +/- 0.0037 -0.2458 +/- 0.0029 -2.1221 +/- 0.0007 ]
[ -0.1193 +/- 0.0026 -0.4083 +/- 0.0029 -0.1314 +/- 0.0006 ]
[ 0.0427 +/- 0.0036 -0.2686 +/- 0.0035 -0.0184 +/- 0.0005 ]
[ 0.0529 +/- 0.0021 -0.2863 +/- 0.0027 0.0821 +/- 0.0004 ]
[ 0.0338 +/- 0.0022 -0.0208 +/- 0.0017 0.0326 +/- 0.0003 ]
[ 0.0824 +/- 0.0019 0.0539 +/- 0.0017 -0.5268 +/- 0.0003 ]
[ 0.0899 +/- 0.0020 0.0557 +/- 0.0018 -0.8509 +/- 0.0003 ]
[ 0.1354 +/- 0.0022 0.0859 +/- 0.0019 -1.2999 +/- 0.0004 ]
[ 0.1641 +/- 0.0022 0.0955 +/- 0.0019 -1.4819 +/- 0.0004 ]
[ -0.0260 +/- 0.0039 -0.1834 +/- 0.0037 -0.0204 +/- 0.0005 ]
Translation vectors (millimeters): //外参平移矩阵
[ 20.4809 +/- 0.9833 -119.1858 +/- 0.6280 412.9415 +/- 3.4706 ]
[ -56.4057 +/- 1.8157 -19.9519 +/- 1.1488 754.6843 +/- 6.3684 ]
[ -49.6146 +/- 1.7748 31.7953 +/- 1.1268 738.4469 +/- 6.2787 ]
[ 14.8648 +/- 1.7827 128.2739 +/- 1.1357 744.9940 +/- 6.3494 ]
[ 96.5079 +/- 1.8262 160.2178 +/- 1.1637 766.2099 +/- 6.4916 ]
[ -68.2884 +/- 1.6775 -47.8024 +/- 1.0592 697.6522 +/- 5.9128 ]
[ -81.0138 +/- 1.7026 -50.3143 +/- 1.0771 707.6428 +/- 5.9961 ]
[ -105.4409 +/- 0.9096 -74.2982 +/- 0.5760 376.4898 +/- 3.1783 ]
[ -104.7996 +/- 1.0105 -62.6256 +/- 0.6406 420.0483 +/- 3.5660 ]
[ -140.0403 +/- 0.9986 4.3986 +/- 0.6411 423.0394 +/- 3.5417 ]
[ -134.8034 +/- 1.0358 52.9123 +/- 0.6590 437.2303 +/- 3.6528 ]
[ -95.4044 +/- 1.0746 107.3640 +/- 0.6767 452.7615 +/- 3.7488 ]
[ -81.0545 +/- 1.0732 126.3488 +/- 0.6716 451.4306 +/- 3.7314 ]
[ -30.1682 +/- 1.8434 -66.5197 +/- 1.1667 767.4144 +/- 6.4651 ]
Camera 2 Intrinsics //相机2内参
-------------------
Focal length (pixels): [ 453.6927 +/- 3.8129 453.9168 +/- 3.8269 ]
Principal point (pixels):[ 311.4093 +/- 1.4798 237.1017 +/- 0.6553 ]
Radial distortion: [ 0.0171 +/- 0.0078 -0.0338 +/- 0.0208 ]
//相机2相对于相机1的位置和方向
Position And Orientation of Camera 2 Relative to Camera 1
---------------------------------------------------------
Rotation of camera 2: [ 0.0076 +/- 0.0012 -0.0140 +/- 0.0024 -0.0024 +/- 0.0002 ]
Translation of camera 2 (millimeters):[ -70.2056 +/- 0.0697 0.1296 +/- 0.0516 0.6029 +/- 0.4883 ]
向OpenCV中写入标定结果并测试。参见双目测距(四)