def run_benchmark(): dataset_path = os.path.join(pwd, "..", "..", "TestData", "RGBD") camera_poses = read_trajectory(os.path.join(dataset_path, "odometry.log")) camera_intrinsics = o3d.camera.PinholeCameraIntrinsic( o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault) volume = o3d.integration.UniformTSDFVolume( length=4.0, resolution=512, sdf_trunc=0.04, color_type=o3d.integration.TSDFVolumeColorType.RGB8, ) s = time.time() for i in range(len(camera_poses)): color = o3d.io.read_image( os.path.join(dataset_path, "color", "{0:05d}.jpg".format(i))) depth = o3d.io.read_image( os.path.join(dataset_path, "depth", "{0:05d}.png".format(i))) rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth( color, depth, depth_trunc=4.0, convert_rgb_to_intensity=False) volume.integrate( rgbd, camera_intrinsics, np.linalg.inv(camera_poses[i].pose), ) time_integrate = time.time() - s s = time.time() mesh = volume.extract_triangle_mesh() time_extract_mesh = time.time() - s s = time.time() pcd = volume.extract_point_cloud() time_extract_pcd = time.time() - s return time_integrate, time_extract_mesh, time_extract_pcd
import cupoch as cph from trajectory_io import read_trajectory import numpy as np if __name__ == "__main__": camera_poses = read_trajectory("../../testdata/rgbd/odometry.log") camera_intrinsics = cph.camera.PinholeCameraIntrinsic( cph.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault) volume = cph.integration.UniformTSDFVolume( length=4.0, resolution=512, sdf_trunc=0.04, color_type=cph.integration.TSDFVolumeColorType.RGB8, ) for i in range(len(camera_poses)): print("Integrate {:d}-th image into the volume.".format(i)) color = cph.io.read_image( "../../testdata/rgbd/color/{:05d}.jpg".format(i)) depth = cph.io.read_image( "../../testdata/rgbd/depth/{:05d}.png".format(i)) rgbd = cph.geometry.RGBDImage.create_from_color_and_depth( color, depth, depth_trunc=4.0, convert_rgb_to_intensity=False) volume.integrate( rgbd, camera_intrinsics, np.linalg.inv(camera_poses[i].pose), ) print("Extract triangle mesh") mesh = volume.extract_triangle_mesh()
# Open3D: www.open3d.org # The MIT License (MIT) # See license file or visit www.open3d.org for details # examples/python/pipelines/rgbd_integration_uniform.py import open3d as o3d from trajectory_io import read_trajectory import numpy as np if __name__ == "__main__": camera_poses = read_trajectory("../../test_data/RGBD/odometry.log") camera_intrinsics = o3d.camera.PinholeCameraIntrinsic( o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault) volume = o3d.pipelines.integration.UniformTSDFVolume( length=4.0, resolution=512, sdf_trunc=0.04, color_type=o3d.pipelines.integration.TSDFVolumeColorType.RGB8, ) for i in range(len(camera_poses)): print("Integrate {:d}-th image into the volume.".format(i)) color = o3d.io.read_image( "../../test_data/RGBD/color/{:05d}.jpg".format(i)) depth = o3d.io.read_image( "../../test_data/RGBD/depth/{:05d}.png".format(i)) rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth( color, depth, depth_trunc=4.0, convert_rgb_to_intensity=False) volume.integrate( rgbd,
def evaluate( airsim_traj_path, meshroom_traj_path, airsim_ply_path, meshroom_ply_path, crop_bbox_path, alignment_matrix_path, ): assert os.path.isfile( airsim_traj_path), f"File not found: '{airsim_traj_path}'" assert os.path.isfile( meshroom_traj_path), f"File not found: '{meshroom_traj_path}'" assert os.path.isfile( airsim_ply_path), f"File not found: '{airsim_ply_path}'" assert os.path.isfile( meshroom_ply_path), f"File not found: '{meshroom_ply_path}'" assert os.path.isfile( crop_bbox_path), f"File not found: '{crop_bbox_path}'" assert os.path.isfile( alignment_matrix_path), f"File not found: '{alignment_matrix_path}'" # TODO update TanksAndTemples's python_toolbox/evaluation/run.py and move # the main "evaluation portion" of the code to the TanksAndTemples class. os.makedirs(EVALUATION_OUT_FOLDER, exist_ok=False) # Load reconstruction and according ground-truth print(meshroom_ply_path) pcd = o3d.io.read_point_cloud(meshroom_ply_path) print(airsim_ply_path) gt_pcd = o3d.io.read_point_cloud(airsim_ply_path) traj = read_trajectory(meshroom_traj_path) # generated .log file gt_traj = read_trajectory(airsim_traj_path) # reference .log file gt_trans = np.loadtxt( alignment_matrix_path) # alignment matrix (<scene>_trans.txt) transformation = trajectory_alignment(None, traj, gt_traj, gt_trans) # Refine alignment by using the actual ground-truth pointcloud vol = o3d.visualization.read_selection_polygon_volume(crop_bbox_path) # Registration refinement in 3 iterations r2 = registration_vol_ds(pcd, gt_pcd, transformation, vol, DTAU, DTAU * 80, 20) r3 = registration_vol_ds(pcd, gt_pcd, r2.transformation, vol, DTAU / 2, DTAU * 20, 20) r = registration_unif(pcd, gt_pcd, r3.transformation, vol, 2 * DTAU, 20) # Histograms and P/R/F1 precision, recall, fscore, *histograms_data = EvaluateHisto( SCENE, filename_mvs=EVALUATION_OUT_FOLDER, source=pcd, target=gt_pcd, trans=r.transformation, crop_volume=vol, voxel_size=DTAU / 2, threshold=DTAU, plot_stretch=5, ) # XXX ^^^^ move to a specific function print("==============================") print("evaluation result : %s" % SCENE) print("==============================") print("distance tau : %.3f" % DTAU) print("precision : %.4f" % precision) print("recall : %.4f" % recall) print("f-score : %.4f" % fscore) print("==============================") # Plotting edges_source, cum_source, edges_target, cum_target = histograms_data plot_graph( SCENE, mvs_outpath=EVALUATION_OUT_FOLDER, fscore=fscore, edges_source=edges_source, cum_source=cum_source, edges_target=edges_target, cum_target=cum_target, plot_stretch=5, dist_threshold=DTAU, )