8000 How to set pycolmap BA parameter/s · Issue #2978 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to set pycolmap BA parameter/s #2978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mattiasmar opened this issue Dec 3, 2024 · 5 comments
Closed

How to set pycolmap BA parameter/s #2978

mattiasmar opened this issue Dec 3, 2024 · 5 comments

Comments

@mattiasmar
Copy link

How does one set max_num_iterations & max_linear_solver_iterations when calling pycolmap.bundle_adjustment?

options = pycolmap.BundleAdjustmentOptions()
pycolmap.bundle_adjustment(reconstruction, options)

As per the documentation the BundleAdjustmentOptions should hold these values, but not anymore in the latest commit.

Context:

#prior: reconstruction folder sfm_path with images.bin, cameras.bin, points3D.bin
os.makedirs(sfm_path,exist_ok=True)
rec.write(sfm_path)
  for _ in range(50):
      # Step 3: Perform triangulation using the existing camera poses
      triangulation.main(
          reference_model=sfm_path,
          sfm_dir = sfm_path,
          image_dir=Path(output_dir),
          pairs=sfm_pairs,
          features=features_path,
          matches=matches_path,
          verbose = False,
          skip_geometric_verification = True
      )
      # # Load the final reconstruction
      reconstruction = pycolmap.Reconstruction(sfm_path)

      # Define bundle adjustment options
      options = pycolmap.BundleAdjustmentOptions()
      options.refine_focal_length = False  # Do not refine focal length
      options.refine_principal_point = False  # Do not refine principal point
      options.refine_extra_params = False  # Do not refine extra parameters
      options.refine_extrinsics = True  # Refine extrinsics
      options.use_gpu = True
      pycolmap.bundle_adjustment(reconstruction, options)
      reconstruction.write(sfm_path)
@ahojnnes
Copy link
Contributor
ahojnnes commented Dec 3, 2024

You should be able to set these using options.solver_options.

@sarlinpe
Copy link
Member
sarlinpe commented Dec 3, 2024

Unfortunately the binding of Ceres::Solver::Options was removed in #2509 on prevent duplication with pyceres. Given how broken the pycolmap-pyceres compatibility is (at least for PyPI wheels on macOS), we maybe shouldn't have done this @B1ueber2y

@mattiasmar
Copy link
Author

Right... when I install pyceres I get an exception when importing pycolmap.
Any other idea on how to limit the BA? I want to do many repeated triangulation / BA, and thought that shorter iterations of BA would help me. I have initial poses that are quite OK, and I'm initializing the reconstruction from those and only finetuning the model with Colmap..

python3
Python 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycolmap
Traceback (most recent call last):
  File "/hloc/venv/lib/python3.10/site-packages/pycolmap/__init__.py", line 7, in <module>
    from . import _core
ImportError: generic_type: type "PositiveExponentialManifold" referenced unknown base type "ceres::Manifold"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/hloc/venv/lib/python3.10/site-packages/pycolmap/__init__.py", line 9, in <module>
    raise RuntimeError(
RuntimeError: 
Cannot import the C++ backend pycolmap._core.
Make sure that you successfully install the package with
  $ python -m pip install pycolmap/

@sarlinpe
Copy link
Member
sarlinpe commented Dec 3, 2024

If using pycolmap 3.11, you'll need the latest pyceres (2.4) - either both compiled from source or both install from PyPI.

@mattiasmar
Copy link
Author
mattiasmar commented Dec 3, 2024

I'm using pycolmap 3.12.0 (latest HEAD).
installing pyceres 2.4 generates the same exception as before.
Compiling pyceres from source (generates version 2.5) avoid the exception and allows to import pycolmap.

B1ueber2y added a commit that referenced this issue Dec 4, 2024
…t pyceres (#2985)

Relevant discussion here: #2978

No need for ``import ceres`` in ``custom_bundle_adjustment.py`` anymore
(relevant discussion: #2896)

---------

Co-authored-by: Johannes Schönberger <jsch@demuc.de>
ahojnnes added a commit that referenced this issue Dec 6, 2024
…t pyceres (#2985)

Relevant discussion here: #2978

No need for ``import ceres`` in ``custom_bundle_adjustment.py`` anymore
(relevant discussion: #2896)

---------

Co-authored-by: Johannes Schönberger <jsch@demuc.de>
HernandoR pushed a commit to HernandoR/colmap that referenced this issue Dec 30, 2024
…t pyceres (colmap#2985)

Relevant discussion here: colmap#2978

No need for ``import ceres`` in ``custom_bundle_adjustment.py`` anymore
(relevant discussion: colmap#2896)

---------

Co-authored-by: Johannes Schönberger <jsch@demuc.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0