Google Waymo Open Dataset数据读取与显示
酱油与清洛
2020年07月28日 04:24
收录于文集
共6篇

数据集准备

WOD数据集基本信息:

频率:10Hz(图像与激光雷达) 

传感器:中距离激光雷达x1,短距离激光雷达x4,相机x5

数据集大小:训练集(812.7G),验证集(204.9G),测试集及域迁移集未下载。

WOD数据集下载:

方式一:

在网站直接网页下载,我不会从网页直接把下载地址转出来,因此只能一个个点着下。

https://waymo.com/open/download/

方式二:

使用gsutil下载。由于数据集过大,而且是远端服务器,因此只能尝试用指令下载。安装谷歌的gsutil工具之后,在WOD给出的谷歌云中的资源链接就可以结合linux的nohup指令离线下载。

https://console.cloud.google.com/storage/browser/waymo_open_dataset_v_1_2_0?pli=1

我自己编写了一个脚本:

download_validation.sh


for i in {0..7}

do

[TAB]echo $i

[TAB]gsutil cp gs://waymo_open_dataset_v_1_2_0/validation/validation_000$i.tar

done


[TAB]意思是在输入的时候输入一个TAB键。在linux下使用以下命令就可以开始在后台下载。

nohup bash download_validation.sh &


数据集显示

将WOD数据集中的点云逐帧显示出来的效果如下视频

文件结构

waymo

├── code

│   └── lidarvideo.py

└── data

    ├── segment-10017090168044687777_6380_000_6400_000_with_camera_labels.tfrecord

    └── segment-10023947602400723454_1120_000_1140_000_with_camera_labels.tfrecord

环境

系统:Ubuntu18.04.04

语言:Python3.6.9

3D显示:Mayavi

开发库:waymo_open_dataset

代码


import os

import tensorflow.compat.v1 as tf

import math

import numpy as np

import itertools

import time

tf.enable_eager_execution()

from waymo_open_dataset.utils import range_image_utils

from waymo_open_dataset.utils import transform_utils

from waymo_open_dataset.utils import  frame_utils

from waymo_open_dataset import dataset_pb2 as open_dataset

from mayavi import mlab

@mlab.animate(delay=100)

def updateAnimation():

framenumber = 0

FILENAME = '../data/segment-10017090168044687777_6380_000_6400_000_with_camera_labels.tfrecord'

dataset = tf.data.TFRecordDataset(FILENAME, compression_type='&#​39;)

MAXPOINT = 200000

for data in dataset:

framenumber += 1

print('Frame Number : {}&#​39;.format(framenumber))

frame = open_dataset.Frame()

frame.ParseFromString(bytearray(data.numpy()))

(range_images, camera_projections, range_image_top_pose) = frame_utils.parse_range_image_and_camera_projection(frame)

points, cp_points = frame_utils.convert_range_image_to_point_cloud(

frame,

range_images,

camera_projections,

range_image_top_pose)

x = [0]*MAXPOINT

y = [0]*MAXPOINT

z = [0]*MAXPOINT

for point in points:

for i in range(len(point)):

x[i] = point[i][0]

y[i] = point[i][1]

z[i] = point[i][2]

fig.mlab_source.set(x=x, y=y, z=z, mode="point&#​34;)

yield

MAXPOINT = 200000

fig = mlab.points3d(np.zeros(MAXPOINT), np.zeros(MAXPOINT), np.zeros(MAXPOINT),

mode="point&#​34;

)

updateAnimation()

mlab.show()


一些问题

这个数据集的数据结构写在了两个protobuf中,对照着数据结构就可以把数据一层层解析出来。

Label.proto:

https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/label.proto

dataset.proto:

https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/dataset.proto

(1) LiDAR data is encoded in this dataset as range images,one for each LiDAR return; 

(2) Data for the first two returns is provided.

实际上LIDAR的XYZ坐标被合起来叫成Range Image。

在dataset.proto中对激光雷达数据的定义是:

message Laser {

  optional LaserName.Name name = 1;

  optional RangeImage ri_return1 = 2;

  optional RangeImage ri_return2 = 3;

}

从中可以知道Laser由两个RangeImage构成,每个RangeImage又被定义为:

message RangeImage {

optional bytes range_image_compressed = 2;

optional bytes camera_projection_compressed = 3;

optional bytes range_image_pose_compressed = 4;

optional MatrixFloat range_image = 1 [deprecated = true];

}

具体的解析在

https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/utils/frame_utils.py

第81行,convert_range_image_to_point_cloud函数。