python mayavi包mayavi.mlab 3维点云数据可视化

使用mayavi包可以实现点云数据可视化

下边为modelnet 40 的一个物体的可视化代码

import os
import h5py
from mayavi import mlab


def getDataFiles(list_filename):
    return [line.rstrip() for line in open(list_filename)]


def load_h5(h5_filename):
    f = h5py.File(h5_filename)
    data = f['data'][:]
    label = f['label'][:]
    return (data, label)


def loadDataFile(filename):
    return load_h5(filename)


def load_h5_data_label_seg(h5_filename):
    f = h5py.File(h5_filename)
    data = f['data'][:]  # (2048, 2048, 3)
    label = f['label'][:]  # (2048, 1)
    seg = f['pid'][:]  # (2048, 2048)
    return (data, label, seg)


BASE_DIR = os.path.dirname(os.path.abspath('__file__'))
FILE_DIR = os.path.join(BASE_DIR, 'ply_data_train0.h5')
data, label = load_h5(FILE_DIR)
point_data_0 = data[4]
x = []
y = []
z = []
for i in range(point_data_0.shape[0]):
    x.append(point_data_0[i][0])
    y.append(point_data_0[i][1])
    z.append(point_data_0[i][2])

mlab.points3d(x, y, z, colormap='spectral')
mlab.show()

结果
python mayavi包mayavi.mlab 3维点云数据可视化_第1张图片 python mayavi包mayavi.mlab 3维点云数据可视化_第2张图片

你可能感兴趣的:(point,cloud)