This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import neuralnet_pytorch as nnt | |
| import torch as T | |
| from torch_scatter import scatter_add | |
| def pointcloud2voxel_fast(pc: T.Tensor, voxel_size: int, grid_size=1., filter_outlier=True): | |
| b, n, _ = pc.shape | |
| half_size = grid_size / 2. | |
| valid = (pc >= -half_size) & (pc <= half_size) | |
| valid = T.all(valid, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def pointcloud_to_depth_map(pointcloud: np.ndarray, theta_res=150, phi_res=32, max_depth=50, phi_min_degrees=60, | |
| phi_max_degrees=100) -> np.ndarray: | |
| """ | |
| All params are set so they match default carla lidar settings | |
| """ | |
| assert pointcloud.shape[1] == 3, 'Must have (N, 3) shape' | |
| assert len(pointcloud.shape) == 2, 'Must have (N, 3) shape' |