Closed pengjili closed 7 months ago
Hi, You can use the following example code to visualize them by using open3d, I once used it to visualize the incremental process of the NeRF-LOAM, but you need to modify it a little bit.
import open3d as o3d
import os.path as osp
import time
import numpy as np
plot_traj_gap = 10
color = [[1, 0, 0]]
vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(o3d.geometry.TriangleMesh.create_coordinate_frame(size=5, origin=[0,0,0]))
# Load the mesh files
data_path = r"F:\iccv2023\visualizer\kitti00"
pose_file=r"F:\iccv2023\visualizer\kitti00\frame_poses_00400.npy"
poses = np.load(pose_file)
points = []
mesh_files = []
index_list = []
for index in range(0,401,10):
path = osp.join(data_path, "mesh_{:05d}.ply".format(index))
mesh_files.append(path)
points.append(list(poses[index][:3,3]))
index_list.append(index)
# ... add more mesh files to the list as needed
pose_file=r"F:\iccv2023\visualizer\kitti00\frame_poses_03199.npy"
poses = np.load(pose_file)
# Initialize the Open3D visualization window
for index in range(500,4501,100):
path = osp.join(data_path, "mesh_{:05d}.ply".format(index))
mesh_files.append(path)
meshs = []
for num in range(len(mesh_files)):
# Load the current mesh file
mesh_file = mesh_files[num]
mesh = o3d.io.read_triangle_mesh(mesh_file)
mesh.compute_vertex_normals()
meshs.append(mesh)
# Loop through the mesh files and display them in the visualization window
for num in range(len(range(0,401,10))):
# Load the current mesh file
mesh = meshs[num]
# Add the mesh to the visualization window
if num != 0:
current_index = index_list[num]
last_index = index_list[num-1]
line_num = 0
moving_index = last_index
while moving_index < current_index:
lines_pcd = o3d.geometry.LineSet()
lines_pcd.lines = o3d.utility.Vector2iVector([[0,1]])
lines_pcd.colors = o3d.utility.Vector3dVector(color) #线条颜色
lines_pcd.points = o3d.utility.Vector3dVector([list(poses[moving_index][:3,3]), list(poses[moving_index+plot_traj_gap][:3,3])])
vis.add_geometry(o3d.geometry.TriangleMesh.create_coordinate_frame(size=5, origin=[0,0,0]).transform(poses[moving_index]))
vis.add_geometry(lines_pcd)
line_num+=1
moving_index = last_index + line_num*plot_traj_gap
vis.add_geometry(mesh)
ctr = vis.get_view_control()
ctr.set_zoom(0.3)
#parameters = o3d.io.read_pinhole_camera_parameters(r"C:\Users\JuneYoung\Desktop\final evaluation\visualizer\camera0.json")
#ctr.convert_from_pinhole_camera_parameters(parameters)
# Update the visualization window
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
if num != len(range(0,401,10))-1:
vis.remove_geometry(mesh)
Hope this can solve your problem.
I finished program running, get final_mesh.ply and frame_poses.npy, how do I visualize them at the same time