colmap / pycolmap

Python bindings for COLMAP
BSD 3-Clause "New" or "Revised" License
857 stars 125 forks source link

Question about pycolmap.incremental_mapping #272

Open Jemian2023 opened 2 months ago

Jemian2023 commented 2 months ago

Hello, I would like to ask a question about pycolmap.incremental_mapping. Can I fix the known image pose for colmap 3D reconstruction in pycolmap.incremental_mapping. In the process, the map points are just triangulated and optimized, at the meantime the pose of query images and fixed.

sarlinpe commented 2 months ago

To optimize only existing 3D points, you can use pycolmap.bundle_adjustment as

opts = {'refine_extrinsics': False, 'refine_focal_length': False, 'refine_extra_params': False}
pycolmap.bundle_adjustment(reconstruction, opts)

If you want to also refine a subset of poses, this is currently only possible by building your own BA problem with pyceres (example here) but we will soon have a much simpler way of doing so by binding the BundleAdjuster (cc @B1ueber2y)

Jemian2023 commented 2 months ago

Sorry, maybe I misspoke what I mean. What I want to express is that I have a bunch of images and their internal parameters and their accurate poses. I want to use the Hloc pipeline, such as the pipeline of "disk+lightglue+netvlad". and then I use Pycolmap to perform 3D reconstruction to generate sparse 3D models. The coordinate system of the image and map points in the model must be consistent with the original image coordinate system. How can I do this? Thank you.

I guess if I can perform as:

options = {"num_threads": min(multiprocessing.cpu_count(), 16),  "fix_existing_images": true, **options}
pycolmap.incremental_mapping(database_path, image_dir, models_path, options=options)

Is this plan feasible? Looking forward to your reply!

sarlinpe commented 1 month ago

If you want to retain the camera poses and intrinsic parameters and simply need a sparse 3D model, you can perform triangulation:

pycolmap.triangulate_points(reconstruction, database_path, image_path, output_path, ...)

You can optionally later refine the parameters with pycolmap.bundle_adjustment.