modelnet40_normal_resampled数据集可视化
f = open(f_file1)
line = f.readline()
points_list = []
normals_list = []
while line:
points = []
for i in line.split(',')[0:3]:
if '\\n' in i:
i.replace(' ', '')
points.append(float(i))
points_list.append(points)
normals = []
for i in line.split(',')[3:6]:
if '\\n' in i:
i.replace(' ', '')
normals.append(float(i))
normals_list.append(points)
line = f.readline()
f.close()
points_data = np.array(points_list)
normals_data = np.array(normals_list)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points_data) # 点数据
pcd.normals = o3d.utility.Vector3dVector(normals_data) # 法线数据
pcd.colors = o3d.utility.Vector3dVector(np.random.uniform(0, 1, (1, 3)))
print(pcd) # 输出点云个数
# print(np.asarray(pcd.points)) # 输出点的三维坐标
# pcd.paint_uniform_color([0, 1, 0])
# # o3d.io.write_point_cloud("", pcd) # 存储为pcd
o3d.visualization.draw_geometries([pcd])