数据格式:
1.时间戳取值为秒*1000000,nuscenes devkit在解析时以精度作为转换。
2.单位旋转矩阵对应的四元数为:[1,0,0,0]
3.传感器外参为传感器到ego的转换
验证数据格式:
1.检测结果格式:
2.跟踪结果格式:
submission {
"meta": {
"use_camera": <bool> -- Whether this submission uses camera data as an input.
"use_lidar": <bool> -- Whether this submission uses lidar data as an input.
"use_radar": <bool> -- Whether this submission uses radar data as an input.
"use_map": <bool> -- Whether this submission uses map data as an input.
"use_external": <bool> -- Whether this submission uses external data as an input.
},
"results": {
sample_token <str>: List[sample_result] -- Maps each sample_token to a list of sample_results.
}
}
sample_result {
"sample_token": <str> -- Foreign key. Identifies the sample/keyframe for which objects are detected.
"translation": <float> [3] -- Estimated bounding box location in meters in the global frame: center_x, center_y, center_z.
"size": <float> [3] -- Estimated bounding box size in meters: width, length, height.
"rotation": <float> [4] -- Estimated bounding box orientation as quaternion in the global frame: w, x, y, z.
"velocity": <float> [2] -- Estimated bounding box velocity in m/s in the global frame: vx, vy.
"tracking_id": <str> -- Unique object id that is used to identify an object track across samples.
"tracking_name": <str> -- The predicted class for this sample_result, e.g. car, pedestrian.
Note that the tracking_name cannot change throughout a track.
"tracking_score": <float> -- Object prediction score between 0 and 1 for the class identified by tracking_name.
We average over frame level scores to compute the track level score.
The score is used to determine positive and negative tracks via thresholding.
}
devkit:
验证方法:
cfg_ = config_factory('tracking_nips_2019')
nusc_eval = TrackingEval(config=cfg_,result_path=elv_json,eval_set='train',output_dir="/data/nuscenes/eval",nusc_version='V1.0-trainval',nusc_dataroot='/data/pipeline_data/liujiao/bicv/nuscenes/data0202',)
nusc_eval.main()
可视化:
nusc = NuScenes(version='V1.0-trainval', dataroot='/data/pipeline_data/liujiao/bicv/nuscenes/data0202', verbose=True)
nusc.list_scenes()
my_scene = nusc.scene[0]
first_sample_token = my_scene['first_sample_token'] #获取第一个sample的token值
my_sample = nusc.get("sample",first_sample_token)
aa = nusc.list_sample(my_sample["token"])
annotation_token = my_sample["anns"][0]
annotation_metadata = nusc.get("sample_annotation",annotation_token)
nusc.render_annotation(annotation_token,out_path="annotation.jpg")
nusc.render_sample_data(my_sample["data"]["CAM_FRONT_LEFT"],out_path="camfrontleft.jpg")
my_instace = nusc.instance[0]
nusc.render_annotation(my_instace['first_annotation_token'],out_path="first_annotation.jpg")
二进制pcd文件
nuscenes数据集中激光雷达点云文件为二进制文件,pcd转二进制文件方法:
def read_pcd_binary(pcd_file,bin_save_file):
with open(pcd_file, 'rb') as f:
# 读取pcd文件头信息
for line in f:
line = line.decode('utf-8')
if line.startswith("DATA"):
break
# 从文件内容中读取三维坐标点云数据
dtype = np.dtype(
[('x', np.float32), ('y', np.float32), ('z', np.float32), ('i', np.uint16), ('r', np.uint16),
('t', np.float64)])
data = np.fromfile(f, dtype=dtype)
data = np.array(data.tolist())
data = np.delete(data, np.where(np.isnan(data))[0], axis=0)
data = np.delete(data, 5, axis=1)
binary_data = data.astype(np.float32).tobytes()
with open(bin_save_file, 'wb') as f:
f.write(binary_data)
点云二进制文件可视化代码:
import os
import open3d as o3d
import numpy as np
def read_bin_point_cloud(bin_file):
try:
with open(bin_file, 'rb') as f:
data = np.fromfile(f, dtype=np.float32)
except FileNotFoundError:
print(f"Error: File '{bin_file}' not found.")
return None
points = data.reshape(-1, 5)
points = points[:,:3]
point_cloud = o3d.geometry.PointCloud()
point_cloud.points = o3d.utility.Vector3dVector(points)
return point_cloud
def visualize_point_cloud(point_cloud):
vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(point_cloud)
render_options = vis.get_render_option()
render_options.point_size = 2
vis.run()
vis.destroy_window()
if __name__ == "__main__":
bin_file_path = "output02.pcd.bin"
point_cloud = read_bin_point_cloud(bin_file_path)
if point_cloud:
visualize_point_cloud(point_cloud)