Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ einops
ninja
yacs
pytest
numpy<=1.26.4 # Tag numpy 1.26.4 for Open3D issue (https://github.com/numpy/numpy/issues/26853)
open3d==0.18.0
numpy
open3d==0.19.0
pycolmap==3.13.0
ruff==0.6.7
clang-format==19.1.0
Expand Down
36 changes: 27 additions & 9 deletions visualize_colmap_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,53 @@ def parse_args():
help="whether to use computed robust ranges",
)
arg_parser.add_argument(
"--scale",
"--point_size",
type=float,
default=1.0,
help="scaling both the lines and the camera geometry",
default=2.0,
help="Point size",
)
arg_parser.add_argument(
"--cam_scale",
type=float,
default=1.0,
help="scale of the camera geometry",
)
arg_parser.add_argument(
"--reproj_error_thresh",
type=float,
default=2.0,
help="reprojection error threshold",
)
args = arg_parser.parse_args()
return args


def vis_colmap_reconstruction(recon: pycolmap.Reconstruction, ranges=None):
def vis_colmap_reconstruction(
args, recon: pycolmap.Reconstruction, ranges=None
):
vis = o3d.visualization.Visualizer()
vis.create_window(height=1080, width=1920)
points = np.array([point.xyz for _, point in recon.points3D.items()])
pcd = limapvis.open3d_get_points(points, ranges=ranges)
pts = np.array([p.xyz for p in recon.points3D.values()], dtype=np.float32)
if args.reproj_error_thresh > 0.0:
errs = np.array(
[p.error for p in recon.points3D.values()], dtype=np.float32
)
mask = errs <= args.reproj_error_thresh # e.g. keep colored, low-error
pts = pts[mask]
print(f"Number of valid points for visualization: {pts.shape[0]}")
pcd = limapvis.open3d_get_points(pts, ranges=ranges)
vis.add_geometry(pcd)
imagecols = pointsfm.convert_colmap_to_imagecols(recon)
camera_set = limapvis.open3d_get_cameras(
imagecols,
ranges=ranges,
scale_cam_geometry=args.scale * args.cam_scale,
scale=args.scale,
scale_cam_geometry=args.cam_scale,
)
vis.add_geometry(camera_set)

opt = vis.get_render_option()
opt.point_size = args.point_size

vis.run()
vis.destroy_window()

Expand All @@ -60,7 +78,7 @@ def main(args):
if args.use_robust_ranges:
points = np.array([point.xyz for _, point in recon.points3D.items()])
ranges = limapvis.compute_robust_range_points(points)
vis_colmap_reconstruction(recon, ranges=ranges)
vis_colmap_reconstruction(args, recon, ranges=ranges)


if __name__ == "__main__":
Expand Down