상세 컨텐츠

본문 제목

Visualize 3D Point Cloud using Matplotlib

PyTorch

by Riella 2021. 3. 24. 01:21

본문

728x90

Reference: SnackCode, Marker

# x/y/z data should be numpy array (or 1D tensor using cpu - but I am not sure)
# input here is pointcloud tensor which uses gpu, so I converted into numpy array
# If the tensor shape is N=batch, P=2048, D=3, call it for individual pcl
# or loop through batch and call this function

def matplotlib_3d_ptcloud(output_pcl):
    data = output_pcl.detach().cpu().numpy()
    xdata = data[0][:,0].squeeze()
    ydata = data[0][:,1].squeeze()
    zdata = data[0][:,2].squeeze()

    fig = plt.figure(figsize=(15, 15))
    ax = plt.axes(projection='3d')

    ax.scatter3D(xdata, ydata, zdata, marker='o')
    plt.show()

 

관련글 더보기

댓글 영역