如何获得相机标定矩阵?
How to get camera calibration matrices?
我目前正在试验 ORB SLAM 2 and a stereo camera like this。我正在使用 2.8mm 和可选的 3.6mm 镜头,左右分辨率为 640x480 像素 camera/image。
ORB SLAM 2 让我可以在设置文件 (*.yaml) 中定义几个 distortion/rectifying 参数,例如:
fx, fy, cx, cy
k1, k2, p1, p2
我使用棋盘 like described here (9x7 inner corners and 70mm square length). Later on I used this automated calibration program from MRPT 进行了 OpenCV 相机校准,这给了我相同的结果,但绊脚石更少。
但是,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.) 我的假设是否正确,即 D
是 distortion coefficients
而 K
是 intrinsic matrix
来自棋盘校准程序?
B.)在settings.yaml
中定义fx
、fy
、cx
、cy
就足够了ORB SLAM 2的图像预校正和成功运行?
C.) 成功运行 ORB SLAM 2 需要 R
和 P
矩阵吗?
D.)如何获取R
和P
矩阵?使用检查板的 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
在我看来,有几种校准工具箱用于校准单目、立体或多摄像头。
第一个是ros_camera_calibration。 运行ning 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,最后会得到投影矩阵和整流变换
我目前正在试验 ORB SLAM 2 and a stereo camera like this。我正在使用 2.8mm 和可选的 3.6mm 镜头,左右分辨率为 640x480 像素 camera/image。
ORB SLAM 2 让我可以在设置文件 (*.yaml) 中定义几个 distortion/rectifying 参数,例如:
fx, fy, cx, cy
k1, k2, p1, p2
我使用棋盘 like described here (9x7 inner corners and 70mm square length). Later on I used this automated calibration program from MRPT 进行了 OpenCV 相机校准,这给了我相同的结果,但绊脚石更少。
但是,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.) 我的假设是否正确,即 D
是 distortion coefficients
而 K
是 intrinsic matrix
来自棋盘校准程序?
B.)在settings.yaml
中定义fx
、fy
、cx
、cy
就足够了ORB SLAM 2的图像预校正和成功运行?
C.) 成功运行 ORB SLAM 2 需要 R
和 P
矩阵吗?
D.)如何获取R
和P
矩阵?使用检查板的 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
在我看来,有几种校准工具箱用于校准单目、立体或多摄像头。
第一个是ros_camera_calibration。 运行ning 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,最后会得到投影矩阵和整流变换