ORB_SLAM2中标定数据的问题

在使用ORB_SLAM2的过程中,我使用Kinect v2作为摄像机,而在使用之前需要对Kinect进行标定的工作。幸好iai_kinect2这个驱动提供了标定的工具[1]。按照说明操作,获得了标定的数据,如calib_color.yaml文件中包含了摄像机的内参和畸变等参数:

%YAML:1.0
cameraMatrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 1.0550860028898474e+03, 0., 9.7022756868552835e+02, 0.,
1.0557186689448556e+03, 5.2645231780561619e+02, 0., 0., 1. ]
distortionCoefficients: !!opencv-matrix
rows: 1
cols: 5
dt: d
data: [ 5.0049307122037007e-02, -5.9715363588982606e-02,
-1.6247803478461531e-03, -1.3650166721283822e-03,
1.2513177850839602e-02 ]
rotation: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 1., 0., 0., 0., 1., 0., 0., 0., 1. ]
projection: !!opencv-matrix
rows: 4
cols: 4
dt: d
data: [ 1.0550860028898474e+03, 0., 9.7022756868552835e+02, 0., 0.,
1.0557186689448556e+03, 5.2645231780561619e+02, 0., 0., 0., 1.,
0., 0., 0., 0., 1. ]

然后根据下式,提取上面的数据,填到ORB_SLAM2定义的校正参数yaml文件中[2]

cameraMatrix:

$$\left[ {\begin{array}{*{20}{c}} {f_x}&0&{c_x}\ 0&{f_y}&{c_y}\ 0&0&1 \end{array}} \right]$$

distortionCoefficients:

$$\left[ {\begin{array}{*{20}{c}} {k_1}&{k_2}&{p_1}&{p_2}&{k_3} \end{array}} \right]$$

然后yaml文件内容如下:

%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 1.0550860028898474e+03
Camera.fy: 1.0557186689448556e+03
Camera.cx: 9.7022756868552835e+02
Camera.cy: 5.2645231780561619e+02

Camera.k1: 5.0049307122037007e-02
Camera.k2: -5.9715363588982606e-02
Camera.p1: -1.6247803478461531e-03
Camera.p2: -1.3650166721283822e-03
Camera.k3: 1.2513177850839602e-02

Camera.width: 960
Camera.height: 540

# Camera frames per second
Camera.fps: 30.0

# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1

# IR projector baseline times fx (aprox.)
Camera.bf: 40.0

# Close/Far threshold. Baseline times.
ThDepth: 50.0

# Deptmap values factor
DepthMapFactor: 1000.0

#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------

# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000

# ORB Extractor: Scale factor between levels in the scale pyramid
ORBextractor.scaleFactor: 1.2

# ORB Extractor: Number of levels in the scale pyramid
ORBextractor.nLevels: 8

# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7

#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1
Viewer.GraphLineWidth: 0.9
Viewer.PointSize:2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500

在解决了双重标定的问题后[3],我使用qhd质量(960x540)的图片跑ORB_SLAM2程序,发现无论是单目模式还是RGBD模式的结果都不堪理想。经过排查后,发现还是标定数据的问题。

在iai_kinect2的标定程序中,使用的FullHD(1920x1080)分辨率图片,所以得到的计算机内参数据是针对1920x1080这个分辨率的;而我在ORB_SLAM2中,使用的是QHD(960x540)分辨率的图片。为了使用标定数据与使用照片对应,需要对1920x1080下的标定数据作出处理,对内参数据根据分辨率按比例进行缩减[4],在这里,需要对$f_x$, $f_y$, $c_x$, $c_y$的值乘以一个0.5。

最终yaml文件内容如下:

%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 527.54300144
Camera.fy: 527.85933447
Camera.cx: 485.11378434
Camera.cy: 263.2261589

Camera.k1: 5.0049307122037007e-02
Camera.k2: -5.9715363588982606e-02
Camera.p1: -1.6247803478461531e-03
Camera.p2: -1.3650166721283822e-03
Camera.k3: 1.2513177850839602e-02

...

重新运行ORB_SLAM2,问题解决。


  1. https://github.com/code-iai/iai_kinect2/tree/master/kinect2_calibration

  2. http://www.jianshu.com/p/c3e8c88edb64

  3. http://luohanjie.com/2017-03-30/dual-calibration-problem-in-orb-slam2-and-iai-kinect2.html

  4. http://dsp.stackexchange.com/questions/6055/how-does-resizing-an-image-affect-the-intrinsic-camera-matrix/6057#6057