(points,
                     voxel_size,
                     coors_range,
                     max_points=35,
                     reverse_index=True,
                     max_voxels=20000)
return voxels, coors, num_points_per_voxel
convert kitti points(N, >=3) to voxels. This version calculate
    everything in one loop. now it takes only 4.2ms(complete point cloud) 
    with jit and 3.2ghz cpu.(don't calculate other features)
    Note: this function in ubuntu seems faster than windows 10.

    Args:
        points: [N, ndim] float tensor. points[:, :3] contain xyz points and
            points[:, 3:] contain other information such as reflectivity.
        voxel_size: [3] list/tuple or array, float. xyz, indicate voxel size
        coors_range: [6] list/tuple or array, float. indicate voxel range.
            format: xyzxyz, minmax
        max_points: int. indicate maximum points contained in a voxel.
        reverse_index: boolean. indicate whether return reversed coordinates.
            if points has xyz format and reverse_index is True, output 
            coordinates will be zyx format, but points in features always
            xyz format.
        max_voxels: int. indicate maximum voxels this function create.
            for second, 20000 is a good choice. you should shuffle points
            before call this function because max_voxels may drop some points.

    Returns:
        voxels: [M, max_points, ndim] float tensor. only contain points.
        coordinates: [M, 3] int32 tensor.
        num_points_per_voxel: [M] int32 tensor.
convert kitti points(N, >=3) to voxels. This version calculate
    everything in one loop. now it takes only 4.2ms(complete point cloud) 
    with jit and 3.2ghz cpu.(don't calculate other features)
    Note: this function in ubuntu seems faster than windows 10.
convert kitti points ( N > = 3 ) to voxels . This version calculate everything in one loop . now it takes only 4 . 2ms ( complete point cloud ) with jit and 3 . 2ghz cpu . ( don t calculate other features ) Note : this function in ubuntu seems faster than windows 10 .
def points_to_voxel(points,
                     voxel_size,
                     coors_range,
                     max_points=35,
                     reverse_index=True,
                     max_voxels=20000):
    """convert kitti points(N, >=3) to voxels. This version calculate
    everything in one loop. now it takes only 4.2ms(complete point cloud) 
    with jit and 3.2ghz cpu.(don't calculate other features)
    Note: this function in ubuntu seems faster than windows 10.

    Args:
        points: [N, ndim] float tensor. points[:, :3] contain xyz points and
            points[:, 3:] contain other information such as reflectivity.
        voxel_size: [3] list/tuple or array, float. xyz, indicate voxel size
        coors_range: [6] list/tuple or array, float. indicate voxel range.
            format: xyzxyz, minmax
        max_points: int. indicate maximum points contained in a voxel.
        reverse_index: boolean. indicate whether return reversed coordinates.
            if points has xyz format and reverse_index is True, output 
            coordinates will be zyx format, but points in features always
            xyz format.
        max_voxels: int. indicate maximum voxels this function create.
            for second, 20000 is a good choice. you should shuffle points
            before call this function because max_voxels may drop some points.

    Returns:
        voxels: [M, max_points, ndim] float tensor. only contain points.
        coordinates: [M, 3] int32 tensor.
        num_points_per_voxel: [M] int32 tensor.
    """
    if not isinstance(voxel_size, np.ndarray):
        voxel_size = np.array(voxel_size, dtype=points.dtype)
    if not isinstance(coors_range, np.ndarray):
        coors_range = np.array(coors_range, dtype=points.dtype)
    voxelmap_shape = (coors_range[3:] - coors_range[:3]) / voxel_size
    voxelmap_shape = tuple(np.round(voxelmap_shape).astype(np.int32).tolist())
    if reverse_index:
        voxelmap_shape = voxelmap_shape[::-1]
    # don't create large array in jit(nopython=True) code.
    num_points_per_voxel = np.zeros(shape=(max_voxels, ), dtype=np.int32)
    coor_to_voxelidx = -np.ones(shape=voxelmap_shape, dtype=np.int32)
    voxels = np.zeros(
        shape=(max_voxels, max_points, points.shape[-1]), dtype=points.dtype)
    coors = np.zeros(shape=(max_voxels, 3), dtype=np.int32)
    if reverse_index:
        voxel_num = _points_to_voxel_reverse_kernel(
            points, voxel_size, coors_range, num_points_per_voxel,
            coor_to_voxelidx, voxels, coors, max_points, max_voxels)

    else:
        voxel_num = _points_to_voxel_kernel(
            points, voxel_size, coors_range, num_points_per_voxel,
            coor_to_voxelidx, voxels, coors, max_points, max_voxels)

    coors = coors[:voxel_num]
    voxels = voxels[:voxel_num]
    num_points_per_voxel = num_points_per_voxel[:voxel_num]
    # voxels[:, :, -3:] = voxels[:, :, :3] - \
    #     voxels[:, :, :3].sum(axis=1, keepdims=True)/num_points_per_voxel.reshape(-1, 1, 1)
    return voxels, coors, num_points_per_voxel
def points_to_voxel ( points , voxel_size , coors_range , max_points = 35 , reverse_index = True , max_voxels = 20000 ) : if not isinstance ( voxel_size , np . ndarray ) : voxel_size = np . array ( voxel_size , dtype = points . dtype ) if not isinstance ( coors_range , np . ndarray ) : coors_range = np . array ( coors_range , dtype = points . dtype ) voxelmap_shape = ( coors_range [ 3 : ] - coors_range [ : 3 ] ) / voxel_size voxelmap_shape = tuple ( np . round ( voxelmap_shape ) . astype ( np . int32 ) . tolist ( ) ) if reverse_index : voxelmap_shape = voxelmap_shape [ : : - 1 ] # don't create large array in jit(nopython=True) code. num_points_per_voxel = np . zeros ( shape = ( max_voxels , ) , dtype = np . int32 ) coor_to_voxelidx = - np . ones ( shape = voxelmap_shape , dtype = np . int32 ) voxels = np . zeros ( shape = ( max_voxels , max_points , points . shape [ - 1 ] ) , dtype = points . dtype ) coors = np . zeros ( shape = ( max_voxels , 3 ) , dtype = np . int32 ) if reverse_index : voxel_num = _points_to_voxel_reverse_kernel ( points , voxel_size , coors_range , num_points_per_voxel , coor_to_voxelidx , voxels , coors , max_points , max_voxels ) else : voxel_num = _points_to_voxel_kernel ( points , voxel_size , coors_range , num_points_per_voxel , coor_to_voxelidx , voxels , coors , max_points , max_voxels ) coors = coors [ : voxel_num ] voxels = voxels [ : voxel_num ] num_points_per_voxel = num_points_per_voxel [ : voxel_num ] # voxels[:, :, -3:] = voxels[:, :, :3] - \ #     voxels[:, :, :3].sum(axis=1, keepdims=True)/num_points_per_voxel.reshape(-1, 1, 1) return voxels , coors , num_points_per_voxel