tsinghua-rll / VoxelNet-tensorflow

A 3D object detection system for autonomous driving.
MIT License
453 stars 123 forks source link

data_augmentation #15

Closed Kiwoo closed 6 years ago

Kiwoo commented 6 years ago

In data_aug.py, for rotation and scaling:

    angle = np.random.uniform(-np.pi / 4, np.pi / 4)
    lidar[:, 0:3] = point_transform(lidar[:, 0:3], 0, 0, 0, rz=angle)
    gt_box3d = box_transform(gt_box3d, 0, 0, 0, -angle, 'camera')
    newtag = 'aug_{}_2_{:.4f}'.format(tag, angle).replace('.', '_')

Above is the code for rotation:

It calls box_transform to rotational transform the gt_box3d. At this step, gt_box3d is in 'camera' coordinate.

In box_transform function, it calculates boxes_corner using center_to_corner_box3d function. And the elements in boxes_corner are still 'camera' coordinate.

However, since the point_transform function is written under assumption that the origin of coordinate is the location of Lidar, no matter it rotates around rz or ry, at this step boxes_corner should be in 'Lidar' coordinate.

I think you considered this already in the first option of data augmentation. It first transform to lidar based box and calculated everything needed for transforming and then finally it converts back to 'camera' coordinate using lidar_to_camera_box.

But for the second and the third option of data augmentation, you didn't consider location of the origin of 'camera' coordinate and 'Lidar' coordinate.

So I suggest you to update the code for the second data augmentation, rotation as:

Kiwoo commented 6 years ago

angle = np.random.uniform(-np.pi / 4, np.pi / 4) lidar[:, 0:3] = point_transform(lidar[:, 0:3], tx=0, ty=0, tz=0, rx=0, ry=0, rz=angle) lidar_center_gt_box3d = camera_to_lidar_box(gt_box3d) lidar_center_gt_box3d = box_transform(lidar_center_gt_box3d, tx=0, ty=0, tz=0, r=angle, coordinate='lidar') gt_box3d = lidar_to_camera_box(lidar_center_gt_box3d)

and for the global scaling: factor = np.random.uniform(0.95, 1.05) lidar[:, 0:3] = lidar[:, 0:3] factor lidar_center_gt_box3d = camera_to_lidar_box(gt_box3d) lidar_center_gt_box3d[:, 0:6] = lidar_center_gt_box3d[:, 0:6] factor gt_box3d = lidar_to_camera_box(lidar_center_gt_box3d)

jeasinema commented 6 years ago

Thanks for this issue, fix in 02749c0