博主最近一直都在看3D点云目标检测,且有一个可视化课设要结,还有一个CV课设,太酸爽了。
搜了一些paper,发现3D点云目标检测论文都不带公开源码的,GitHub上找项目配置来配置去总是会报一系列的错误,比如我上一个博客想要把CenterPoint跑起来,结果夭折了,配了半天(且把办公室的电脑重装了n遍系统),最终还是放弃了,毕竟玩不懂nuScenes数据集。
BUT!!!
带YOLO字眼的检测项目简直就是正道的光啊!!而且KITTI数据集明显更容易分析~
那就开始我们的3D点云检测之旅吧。
pip install hexdump
hexdump 000001.bin
import numpy as np
import mayavi.mlab
# 000010.bin这里需要填写文件的位置
pointcloud = np.fromfile(str("velodyne/000001.bin"), dtype=np.float32, count=-1).reshape([-1, 4])
print(pointcloud)
print(pointcloud.shape)
x = pointcloud[:, 0] # x position of point
y = pointcloud[:, 1] # y position of point
z = pointcloud[:, 2] # z position of point
r = pointcloud[:, 3] # reflectance value of point
d = np.sqrt(x ** 2 + y ** 2) # Map Distance from sensor
vals = 'height'
if vals == "height":
col = z
else:
col = d
fig = mayavi.mlab.figure(bgcolor=(0, 0, 0), size=(640, 500))
mayavi.mlab.points3d(x, y, z,
col, # Values used for Color
mode="point",
colormap='spectral', # 'bone', 'copper', 'gnuplot'
# color=(0, 1, 0), # Used a fixed (r,g,b) instead
figure=fig,
)
x = np.linspace(5, 5, 50)
y = np.linspace(0, 0, 50)
z = np.linspace(0, 5, 50)
mayavi.mlab.plot3d(x, y, z)
mayavi.mlab.show()
calib主要和坐标系转换有关。
# 000001.txt calib文件中的内容
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
BEV space – bird eye view space 鸟瞰图空间
Each calibration file contains the following matrices (in row-major order):
P0 (3x4): Projection matrix for left grayscale camera in rectified coordinates 左边灰度相机的投影矩阵,坐标已修正
P1 (3x4): Projection matrix for right grayscale camera in rectified coordinates 右边灰度相机
P2 (3x4): Projection matrix for left color camera in rectified coordinates 左边彩色相机
P3 (3x4): Projection matrix for right color camera in rectified coordinates 右边彩色相机
R0_rect (3x3): Rotation from non-rectified to rectified camera coordinate system 从非矫正到矫正摄像机坐标系统的旋转
Tr_velo_to_cam (3x4): Rigid transformation from Velodyne to (non-rectified) camera coordinates 从Velodyne到(非矫正)相机坐标的刚性转换
Tr_imu_to_velo (3x4): Rigid transformation from IMU to Velodyne coordinates 从IMU到Velodyne坐标的刚性变换
Tr_cam_to_road (3x4): Rigid transformation from (non-rectified) camera to road coordinates 从(非矫正)摄像机到道路坐标的刚性变换,我下载的数据中没有这个矩阵变换。
具体的内容见如下笔记~博主是个喜欢五彩斑斓笔记的女孩子哈哈哈哈哈
000001.txt label内容
Truck 0.00 0 -1.57 599.41 156.40 629.75 189.25 2.85 2.63 12.34 0.47 1.49 69.44 -1.56
Car 0.00 0 1.85 387.63 181.54 423.81 203.12 1.67 1.87 3.69 -16.53 2.39 58.49 1.57
Cyclist 0.00 3 -1.65 676.60 163.95 688.98 193.93 1.86 0.60 2.02 4.59 1.32 45.84 -1.55
DontCare -1 -1 -10 503.89 169.71 590.61 190.13 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 511.35 174.96 527.81 187.45 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 532.37 176.35 542.68 185.27 -1 -1 -1 -1000 -1000 -1000 -10
DontCare -1 -1 -10 559.62 175.83 575.40 183.15 -1 -1 -1 -1000 -1000 -1000 -10
每一行代表一个object,每一行都有16列分别表示不同的含义,具体如下: