【问题标题】:How to get camera calibration matrices?如何获得相机校准矩阵?
【发布时间】:2018-09-01 12:11:55
【问题描述】:

我目前正在试验ORB SLAM 2stereo camera like this。我为左右摄像头/图像使用 2.8 毫米和可选的 3.6 毫米镜头,分辨率为 640x480 像素。

ORB SLAM 2 让我可以使用设置文件 (*.yaml) 定义几个失真/校正参数,例如:

fx, fy, cx, cy
k1, k2, p1, p2

我使用棋盘like described here(9x7 内角和 70mm 正方形长度)进行了 OpenCV 相机校准。后来我使用了这个automated calibration program from MRPT,它给了我相同的结果,但绊脚石更少。

但是,ORB SLAM 2 让我可以定义这些附加参数来预校正图像(如果我理解正确的话):

D: 1x5 Matrix -> Distortion Coefficients aquired from calibration (fx,fy,cx,cy) ?
K: 3x3 Matrix -> Intrinsic Matrix aquired from calibration (k1,k2,p1,p2,k3) ?
R: 3x3 Matrix -> Rectification Transformation ?
P: 3x4 Matrix -> New Projection Matrix ?

我的问题如下(请参阅下面的示例 settings.yaml 文件):

A.) 我的假设是否正确,即Ddistortion coefficientsK 是从棋盘校准过程中获得的intrinsic matrix

B.)settings.yaml中定义fxfycxcy是否足以预校正图像并成功运行ORB SLAM 2?

C.) 我需要RP 矩阵才能成功运行ORB SLAM 2 吗?

D.) 如何获得RP 矩阵?带有检查板的 OpenCV 相机校准程序没有为我提供这些矩阵,对吗?

这是上面提到的 ORB SLAM 2 的settings.yaml 文件的示例:

%YAML:1.0

#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV) 
Camera.fx: 646.53807309613160
Camera.fy: 647.36136487241527
Camera.cx: 320.94123353073792
Camera.cy: 219.07092188981900

Camera.k1: -0.43338537102343577
Camera.k2: 0.46801812273859494
Camera.p1: 0.0039978632628183738
Camera.p2: 0.00023265675941025371

Camera.width: 640
Camera.height: 480

# Camera frames per second 
Camera.fps: 20.0

# stereo baseline times fx
Camera.bf: 38.76

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

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

#--------------------------------------------------------------------------------------------
# Stereo Rectification. Only if you need to pre-rectify the images.
# Camera.fx, .fy, etc must be the same as in LEFT.P
#--------------------------------------------------------------------------------------------
LEFT.width: 640
LEFT.height: 480
LEFT.D: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data:[-0.28340811, 0.07395907, 0.00019359, 1.76187114e-05, 0.0]
LEFT.K: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [458.654, 0.0, 367.215, 0.0, 457.296, 248.375, 0.0, 0.0, 1.0]
LEFT.R:  !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [0.999966347530033, -0.001422739138722922, 0.008079580483432283, 0.001365741834644127, 0.9999741760894847, 0.007055629199258132, -0.008089410156878961, -0.007044357138835809, 0.9999424675829176]
LEFT.P:  !!opencv-matrix
   rows: 3
   cols: 4
   dt: d
   data: [435.2046959714599, 0, 367.4517211914062, 0,  0, 435.2046959714599, 252.2008514404297, 0,  0, 0, 1, 0]

RIGHT.width: 640
RIGHT.height: 480
RIGHT.D: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data:[-0.28368365, 0.07451284, -0.00010473, -3.555907e-05, 0.0]
RIGHT.K: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [457.587, 0.0, 379.999, 0.0, 456.134, 255.238, 0.0, 0.0, 1]
RIGHT.R:  !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [0.9999633526194376, -0.003625811871560086, 0.007755443660172947, 0.003680398547259526, 0.9999684752771629, -0.007035845251224894, -0.007729688520722713, 0.007064130529506649, 0.999945173484644]
RIGHT.P:  !!opencv-matrix
   rows: 3
   cols: 4
   dt: d
   data: [435.2046959714599, 0, 367.4517211914062, -47.90639384423901, 0, 435.2046959714599, 252.2008514404297, 0, 0, 0, 1, 0]

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

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

# 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: 12
ORBextractor.minThFAST: 3

#--------------------------------------------------------------------------------------------
# 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

【问题讨论】:

  • 不幸的是,我不了解 ORB SLAM,所以我无法回答您的其他问题,但我可以提供有关第一个问题的信息。 D: 1x5 matrix: Distortion coefficients k1 k2 p1 p2 k3, K: 3x3 matrix: Intrinsic parameters [fx, 0, cx; 0, fy, cy; 0, 0, 1], R: 3x3 matrix: Probably rectification matrix(same as ROS), P: 3x4 matrix: Final projection matrix, this should be able to calculated by using previous matrices if your framework is performing that.
  • 感谢您迄今为止的帮助。我将进一步试验这些值并报告。

标签: opencv camera-calibration orb slam


【解决方案1】:

在我看来,有几种校准工具箱可用于校准单目、立体或多摄像头。

第一个是ros_camera_calibration。在运行 ORBSLAM 时,我更喜欢使用这个包来获取单个运动相机的内在参数。移动标定板后获取内参和畸变系数以及投影矩阵。

第二个,我最近用的是Kalibr。它不仅可以校准多相机,还可以联合校准相机和惯性测量单元(IMU)。

此外,您还可以使用MATLAB获取相机的内参。

至于你的问题,这里是我不完美的答案。

Q.A:K(fx, fy, cx,cy)代表相机的内在参数,畸变系数分别为k1,k2,p1.p2

Q.B:就我而言,获得包括 fx、fy、cx、cy 在内的内在参数足以用您自己的相机运行 ORBSLAM2。

Q.C&D,如果你选择使用this ROS package,最后你会得到投影矩阵和整流变换。

【讨论】:

  • 感谢您的全面回答!
猜你喜欢
  • 2011-05-13
  • 1970-01-01
  • 2013-10-07
  • 2015-03-16
  • 1970-01-01
  • 2012-04-28
  • 2019-08-10
  • 2014-09-13
  • 2018-10-19
相关资源
最近更新 更多