import os
import numpy as np
import open3d as o3d
import time
#打开文件路径
files = os.listdir("experiment_1_rec/")
files.sort(key=lambda x:int(x.split('.')[0])) #按照文件名的顺序排序
vis = o3d.visualization.Visualizer()
##创建播放窗口
vis.create_window()
pointcloud = o3d.geometry.PointCloud()
to_reset = True
vis.add_geometry(pointcloud)
for f in files:
pcd = o3d.io.read_point_cloud("experiment_1_rec/"+f) #此处读取的ply文件,也可读取其他格式的
print(str("experiment_1_rec/"+f))
pcd = np.asarray(pcd.points).reshape((-1, 3))
pointcloud.points = o3d.utility.Vector3dVector(pcd)
vis.update_geometry(pointcloud)
if to_reset:
vis.reset_view_point(True)
to_reset = False
vis.poll_events()
vis.update_renderer()
time.sleep(0.5)