Args: gt_boxes: (N, 7), [x, y, z, dx, dy, dz, heading, [vx], [vy]] points: (M, 3 + C), rot_range: [min, max] Returns:
(gt_boxes, points, rot_range)
| 328 | |
| 329 | |
| 330 | def local_rotation(gt_boxes, points, rot_range): |
| 331 | """ |
| 332 | Args: |
| 333 | gt_boxes: (N, 7), [x, y, z, dx, dy, dz, heading, [vx], [vy]] |
| 334 | points: (M, 3 + C), |
| 335 | rot_range: [min, max] |
| 336 | Returns: |
| 337 | """ |
| 338 | # augs = {} |
| 339 | for idx, box in enumerate(gt_boxes): |
| 340 | noise_rotation = np.random.uniform(rot_range[0], rot_range[1]) |
| 341 | # augs[f'object_{idx}'] = noise_rotation |
| 342 | points_in_box, mask = get_points_in_box(points, box) |
| 343 | |
| 344 | centroid_x = box[0] |
| 345 | centroid_y = box[1] |
| 346 | centroid_z = box[2] |
| 347 | |
| 348 | # tranlation to axis center |
| 349 | points[mask, 0] -= centroid_x |
| 350 | points[mask, 1] -= centroid_y |
| 351 | points[mask, 2] -= centroid_z |
| 352 | box[0] -= centroid_x |
| 353 | box[1] -= centroid_y |
| 354 | box[2] -= centroid_z |
| 355 | |
| 356 | # apply rotation |
| 357 | points[mask, :] = common_utils.rotate_points_along_z(points[np.newaxis, mask, :], np.array([noise_rotation]))[0] |
| 358 | box[0:3] = common_utils.rotate_points_along_z(box[np.newaxis, np.newaxis, 0:3], np.array([noise_rotation]))[0][0] |
| 359 | |
| 360 | # tranlation back to original position |
| 361 | points[mask, 0] += centroid_x |
| 362 | points[mask, 1] += centroid_y |
| 363 | points[mask, 2] += centroid_z |
| 364 | box[0] += centroid_x |
| 365 | box[1] += centroid_y |
| 366 | box[2] += centroid_z |
| 367 | |
| 368 | gt_boxes[idx, 6] += noise_rotation |
| 369 | if gt_boxes.shape[1] > 8: |
| 370 | gt_boxes[idx, 7:9] = common_utils.rotate_points_along_z( |
| 371 | np.hstack((gt_boxes[idx, 7:9], np.zeros((gt_boxes.shape[0], 1))))[np.newaxis, :, :], |
| 372 | np.array([noise_rotation]) |
| 373 | )[0][:, 0:2] |
| 374 | |
| 375 | return gt_boxes, points |
| 376 | |
| 377 | def local_frustum_dropout_top(gt_boxes, points, intensity_range): |
| 378 | """ |
nothing calls this directly
no test coverage detected