Esempio n. 1
0
def downsample_random_gpu(points, labels, sample_stride=0.01):
    points[:, :3] -= np.min(points[:, :3], axis=0, keepdims=True)
    points = np.ascontiguousarray(points, dtype=np.float32)
    labels = np.ascontiguousarray(labels, dtype=np.int32)
    ds_points, ds_labels = PointsUtil.GridDownSample(points, labels,
                                                     sample_stride)
    return ds_points, ds_labels
Esempio n. 2
0
def points2voxel_gpu_s3dis(points, split_num, gpu_index=0):
    '''
    :param points: n,k,3
    :param split_num:
    :return:
    '''
    pts = np.ascontiguousarray(np.copy(points[:, :, :3]))
    pts[:, :, :2] += 0.5
    voxels = PointsUtil.Points2VoxelBatchGPU(pts, split_num, gpu_index)
    voxels[voxels > 1.0] = 1.0

    return voxels
Esempio n. 3
0
def points2covars_gpu(points,nidxs,nn_size,gpu_index=0):
    '''

    :param points: n,k,3
    :param ndixs:  n,k,nn_size
    :param nn_size:
    :param gpu_index:
    :return:
        covars: n,k,9
    '''

    nidxs=np.ascontiguousarray(nidxs,dtype=np.int32)
    points=np.ascontiguousarray(points,dtype=np.float32)
    covars=PointsUtil.ComputeCovars(points,nidxs,nn_size,gpu_index)

    return covars
Esempio n. 4
0
def test_random_rotate_sample_block():
    train_list,test_list=get_block_train_test_split()
    import random
    random.shuffle(train_list)
    for fn in train_list[:1]:
        points,labels=read_room_pkl('../data/S3DIS/room_block_10_10/{}'.format(fn))

        labels=np.asarray(labels,dtype=np.int32)
        points=np.ascontiguousarray(points,dtype=np.float32)
        points[:,:2]-=np.min(points[:,:2],axis=0,keepdims=True)
        max_coor=np.max(points[:,:2],axis=0)
        maxx,maxy=max_coor[0],max_coor[1]
        begin = time.time()
        block_points_list,block_labels_list=PointsUtil.UniformSampleBlock(points,labels,1.0,5.0,0.8,10,maxx,maxy)

        print 'cost {} s'.format(time.time()-begin)
        for i,pts in enumerate(block_points_list):
            output_points('test/{}.txt'.format(i),pts)
Esempio n. 5
0
def points2voxel_color_gpu(points,split_num,gpu_index=0):
    '''
    :param points:      n,k,6 xyz:(-0.5,0.5)(-0.5,0.5)(0.0,1.0) rgb:(-1.0,1.0)*3
    :param split_num:
    :param gpu_index:
    :return:
    '''
    pts = np.ascontiguousarray(np.copy(points[:, :, :6]))
    pts[:, :, :2] += 0.5
    pts[:, :, 3:] += 1.0
    pts[:, :, 3:] /= 2.0
    voxels = PointsUtil.Points2VoxeColorlBatchGPU(pts, split_num, gpu_index)
    voxel_state,voxel_color=voxels[:,:,0],voxels[:,:,1:]
    voxel_color/=voxel_state[:,:,None]+1e-6
    voxel_state[voxel_state>1.0]=1.0
    voxel_color[voxel_state>1.0]=1.0

    return voxel_state,voxel_color
Esempio n. 6
0
        maxx,maxy=max_coor[0],max_coor[1]
        begin = time.time()
        block_points_list,block_labels_list=PointsUtil.UniformSampleBlock(points,labels,1.0,5.0,0.8,10,maxx,maxy)

        print 'cost {} s'.format(time.time()-begin)
        for i,pts in enumerate(block_points_list):
            output_points('test/{}.txt'.format(i),pts)

if __name__=="__main__":
    train_list,test_list=get_block_train_test_split()
    import random
    random.shuffle(train_list)
    for fn in train_list[:1]:
        points,labels=read_room_pkl('../data/S3DIS/room_block_10_10/'+fn)
        points=np.ascontiguousarray(points,dtype=np.float32)
        labels=np.ascontiguousarray(labels,dtype=np.int32)
        points[:,:3]-=np.min(points[:,:3],axis=0,keepdims=True)
        output_points('original.txt', points)
        begin = time.time()
        points,labels=PointsUtil.GridDownSample(points,labels,0.05)
        print 'cost {} s'.format(time.time()-begin)

        colors=get_class_colors()

        output_points('downsample.txt', points)





Esempio n. 7
0
    :return:
        covars: n,k,9
    '''

    nidxs=np.ascontiguousarray(nidxs,dtype=np.int32)
    points=np.ascontiguousarray(points,dtype=np.float32)
    covars=PointsUtil.ComputeCovars(points,nidxs,nn_size,gpu_index)

    return covars


if __name__=="__main__":
    from draw_util import output_points
    import time
    points=np.loadtxt('/home/liuyuan/tmp/0_8_true.txt',dtype=np.float32)
    points[:,:2]+=0.5
    print np.min(points,axis=0)
    print np.max(points,axis=0)
    output_points('points.txt',points)

    bg=time.time()
    points=np.repeat(points[None,:,:],2,axis=0)
    # print points.shape

    voxels=PointsUtil.Points2VoxelBatchGPU(points,30)
    print 'cost {} s'.format(time.time()-bg)
    voxels=voxels[0]
    voxel_points= voxel2points(voxels)
    voxel_points=voxel_points.astype(np.float32)
    voxel_points[:,:3]/=np.max(voxel_points[:,:3],axis=0,keepdims=True)
    output_points('voxels.txt',voxel_points)