| import viser | |
| import open3d as o3d | |
| import numpy as np | |
| import sys | |
| import time | |
| if len(sys.argv) < 2: | |
| print("Usage: python vis.py <path_to_pcd_file>") | |
| sys.exit(1) | |
| pcd_file = sys.argv[1] | |
| pcd = o3d.io.read_point_cloud(pcd_file) | |
| points = np.asarray(pcd.points) | |
| colors = np.asarray(pcd.colors).astype(float) if pcd.has_colors() else None | |
| # 启动 Viser 服务器 | |
| server = viser.ViserServer(port=8088) # 可自定义端口 | |
| server.scene.background_color = (0.1, 0.1, 0.1) | |
| # 添加点云 | |
| server.add_point_cloud( | |
| name="/pointcloud", | |
| points=points, | |
| colors=colors, | |
| point_size=0.003, | |
| ) | |
| # Keep the script running | |
| while True: | |
| time.sleep(0.1) |