一.环境准备
参考上篇文章:
Kalibr&TartanCalib开源项目进行单目相机标定
1.使用的相机
双目相机,成像图像一张,可利用python工具进行图像分割成两张,并保存在相应文件夹中,我的文件夹格式;
-database
-cam0
.jpg
-cam1
.jpg
二.资源准备
标定板yaml文件、.bag文件打包方式、相关注意事项参考上篇文章:
Kalibr&TartanCalib开源项目进行单目相机标定
三.执行命令-输出
rosrun kalibr kalibr_calibrate_cameras --target checkerboard.yaml --models pinhole-radtan pinhole-radtan --topics /cam0/image_raw /cam1/image_raw --bag multiCap.bag
注意事项:models参数与topics参数跟的相机顺序要匹配;执行报错则建议手敲指令
执行 参数说明可通过rosrun kalibr kalibr_calibrate_cameras -h命令了解
usage:
Example usage to calibrate a camera system with two cameras using an aprilgrid.cam0: omnidirection model with radial-tangential distortion
cam1: pinhole model with equidistant distortionkalibr_calibrate_cameras --models omni-radtan pinhole-equi --target aprilgrid.yaml \
--bag MYROSBAG.bag --topics /cam0/image_raw /cam1/image_rawexample aprilgrid.yaml:
target_type: 'aprilgrid'
tagCols: 6
tagRows: 6
tagSize: 0.088 #m
tagSpacing: 0.3 #percent of tagSizeoptional arguments:
-h, --help show this help message and exit
--models MODELS [MODELS ...]
The camera model ['pinhole-radtan', 'pinhole-equi', 'pinhole-fov', 'omni-none', 'omni-radtan', 'eucm-none', 'ds-none']
to estimateData source:
--bag BAGFILE The bag file with the data
--topics TOPICS [TOPICS ...]
The list of image topics
--bag-from-to bag_from_to bag_from_to
Use the bag data starting from up to this time [s]Calibration target configuration:
--target TARGETYAML Calibration target configuration as yaml fileImage synchronization:
--approx-sync MAX_DELTA_APPROXSYNC
Time tolerance for approximate image synchronization [s] (default: 0.02)Calibrator settings:
--qr-tol QRTOL The tolerance on the factors of the QR decomposition (default: 0.02)
--mi-tol MITOL The tolerance on the mutual information for adding an image. Higher means fewer images will be added. Use -1 to force
all images. (default: 0.2)
--no-shuffle Do not shuffle the dataset processing orderOutlier filtering options:
--no-outliers-removal
Disable corner outlier filtering
--no-final-filtering Disable filtering after all views have been processed.
--min-views-outlier MINVIEWOUTLIER
Number of raw views to initialize statistics (default: 20)
--use-blakezisserman Enable the Blake-Zisserman m-estimator
--plot-outliers Plot the detect outliers during extraction (this could be slow)Output options:
--verbose Enable (really) verbose output (disables plots)
--show-extraction Show the calibration target extraction. (disables plots)
--plot Plot during calibration (this could be slow).
--dont-show-report Do not show the report on screen after calibration.
四.输出文件
通过上述步骤后可得到一个yaml文件和一个txt文档。
yaml文件内包含我们所需的相机内参、畸变系数、和双目标定特有的外参(旋转矩阵和平移向量)
黄色框内的T_cn_cnm1
是一个变换矩阵 ,这个矩阵可以分解为旋转矩阵R
和平移向量t,r11
至r33
是旋转矩阵R
的元素,tx
、ty
、tz
是平移向量t
的元素
T_cn_cnm1 = [ R | t ]
= [ r11 r12 r13 tx ]
[ r21 r22 r23 ty ]
[ r31 r32 r33 tz ]
[ 0 0 0 1 ]
五.结语
通过TartanCalib这个工具可以很好的对双目相机进行标定,针对自己不同种类的摄像头,它提供了不同的相机模型供使用。当然,具体的标定性能这里不做说明也没有参考,TartanCalib与Kalibr不仅仅可以用于双目相机的标定,也适用与单目相机标定、IMU标定、IMU与双目联合标定等场景,想了解更多信息,参考github官方:
kalibr:
https://github.com/ethz-asl/kalibr/wiki/multiple-camera-calibration
tartancalib:
https://github.com/D2SLAM-Fusion/tools-tartancalib?tab=readme-ov-file