nuscenes数据集关于毫米波雷达的操作

一、对应的sample提取对应的radar文件

nusc = NuScenes(version='v1.0-mini',dataroot= '../data/nuscenes/',verbose=True)


mysample=nusc.sample[10]        #sample
print(mysample)
#nusc.render_sample_data(mysample['data']['RADAR_FRONT'])
radartoken= 'dfce1c7ce9994dc3872ccd4809b56c94'      #提取出对应的radartoken
sample_data=nusc.get('sample_data',radartoken)
filename=sample_data.get('filename')
print(filename)

二、radar点云可视化

nusc.render_sample_data(mysample['data']['RADAR_FRONT']) #只显示radar点云

nusc.render_pointcloud_in_image(mysample['token'],pointsensor_channel='RADAR_FRONT')  #将点云投到图像上

三、将点云投影到前摄像头像素坐标系中

nuscenes毫米波雷达转换的基本思路:

1.将毫米波点云从传感器坐标转到自车坐标—>2.将自车坐标系转到世界坐标系----->3.将图像时间戳从全局转向自车坐标系—>4.从自车再转到相机坐标系

#step1首先获取一个sample的cam_front的token和radar的token,进而获得前摄像头与radar的sample_data
nusc = NuScenes(version='v1.0-mini',dataroot= '../data/nuscenes/',verbose=True)
mysample=nusc.sample[10]
print(mysample)
radartoken= 'dfce1c7ce9994dc3872ccd4809b56c94'
camtoken='81b6368f6af9417684cefeb6661a14e7'
#radar的sample_data
rsdata=nusc.get('sample_data',radartoken)
print(rsdata)
#cam的sample_data
csdata=nusc.get('sample_data',camtoken)
#step2将点云从自身传感器坐标系转到自车坐标系框架中
radar_cs = nusc.get('calibrated_sensor', rsdata['calibrated_sensor_token'])
pc.rotate(Quaternion(radar_cs['rotation']).rotation_matrix)    #将四元数转为旋转矩阵,然后再旋转
pc.translate(np.array(radar_cs['translation']))
#step3将点云自车转到世界坐标系框架
poserecord = nusc.get('ego_pose', rsdata['ego_pose_token'])
pc.rotate(Quaternion(poserecord['rotation']).rotation_matrix)
pc.translate(np.array(poserecord['translation']))
step4将图像从世界坐标系转到自身坐标系
poserecord = nusc.get('ego_pose', csdata['ego_pose_token'])
pc.translate(-np.array(poserecord['translation']))
pc.rotate(Quaternion(poserecord['rotation']).rotation_matrix.T)
#将图像从自身转到相机坐标系
cs_record = nusc.get('calibrated_sensor', csdata['calibrated_sensor_token'])
pc.translate(-np.array(cs_record['translation']))
pc.rotate(Quaternion(cs_record['rotation']).rotation_matrix.T)
print(pc.points.shape)    #18*69

你可能感兴趣的:(3d目标检测,目标检测,深度学习,pytorch)