我目前正在尝试ORB SLAM 2和stereo camera like this。我正在使用2.8mm镜头和可选的3.6mm镜头,左右相机/图像的分辨率为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.)我的假设正确吗,
D
是distortion coefficients
,K
是从棋盘校准程序获取的intrinsic matrix
?是否在
fx
中定义了fy
,cx
,cy
,settings.yaml
和R
足以预校正图像并成功运行ORB SLAM 2?)是否需要
P
和R
矩阵才能成功运行ORB SLAM 2?D.)如何获取
P
和settings.yaml
矩阵?带有棋盘的OpenCV摄像机校准程序无法为我提供这些矩阵,对吗?这是上述ORB SLAM 2的ojit_code文件的示例:
%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。在运行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,您将收到投影矩阵和整流变换。
关于opencv - 如何获得相机校准矩阵?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52127975/