KITTI激光雷達點雲解析與圖像反投影


介紹

KITTI作為廣為人知的自動駕駛數據集,很多創業公司喜歡拿來做算法排名。
官網下載比較慢,這里參考文末博客給出百度雲下載(27G)

鏈接:https://pan.baidu.com/s/1-4WchJlcZ2guwcfbHqrdFw
提取碼:grys

解析

我的目的是解析三維激光點雲並投影至二維圖像坐標,得到類似RGBD相機的效果。
需要用到的文件包括:二進制Velodyne點雲、雙目RGB相機左眼cam2圖像、激光到相機矩陣等標定文件

各傳感器坐標在KIT的文章Vision meets Robotics: The KITTI Dataset中給出

參考semantic-kitti-api的開源代碼,使用numpy讀取點雲bin文件reshape為x,y,z,r(回波強度)格式
點雲index從外圈到內圈順時針存儲

# read raw data from binary
scan = np.fromfile(binary, dtype=np.float32).reshape((-1,4))
points = scan[:, 0:3] # lidar xyz (front, left, up)
remissions = scan[:, 3]

標定文件calib/*.txt解讀:

P0: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 0.000000000000e+00 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.875744000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e-03
P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e-03
R0_rect: 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_to_cam: 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_to_velo: 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01

P0-P3為3x4相機投影矩陣,0=gray_L 1=gray_R 2=rgb_L 3=rgb_R
R0_rect為3x3相機旋轉矩陣
Tr_velo_to_cam為3x4激光到相機RT矩陣
點雲對圖像投影使用如下公式

Z[u v 1]T = P2 * R0_rect * Tr_velo_to_cam * [x y z 1]T

寫為齊次形式,R0在右下角補1變為4x4,Tr最后一列補1變為4x4,大寫Z為相機深度

代碼

使用python實現,過濾了激光雷達背后深度為負的點雲,保留圖像寬高內點,深度以colormap表示
源碼與測試數據已開源至github倉庫azureology/kitti-velo2cam: project lidar point cloud to camera image

效果

參考

KITTI數據集下載(百度雲)_u013086672的博客-CSDN博客
Vision meets Robotics: The KITTI Dataset
PRBonn/semantic-kitti-api: SemanticKITTI API for visualizing dataset, processing data, and evaluating results
numpy.logical_or — NumPy v1.19 Manual
matplotlib - python 3 scatter plot gives "ValueError: Masked arrays must be 1-D" even though i am not using any masked array - Stack Overflow


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM