cvg / Hierarchical-Localization

Visual localization made easy with hloc
Apache License 2.0
3.09k stars 573 forks source link

Setting the camera intrinsic parameters #33

Closed ricshaw closed 3 years ago

ricshaw commented 3 years ago

Hi, I was wondering if it was possible to set known camera intrinsic parameters when running pycolmap in the SFM pipeline? And to keep them fixed, rather than colmap optimising for them. I can't find any documentation about this. Thanks

sarlinpe commented 3 years ago

Are you referring to the 3D reconstruction 1) or to the query pose estimation 2) ?

1) The 3D reconstruction uses COLMAP (not pycolmap). An initial value for the focal length is obtained from the EXIF data when importing the images. It is then refined during the reconstruction. It is possible to disable the refinement of intrinsics during BA (like in the triangulation), but you then need to first update the database database.db with the know intrinsics. This needs to be done for each camera (or a single one if shared intrinsics) via SQL queries, after import_images but before run_reconstruction.

2) pycolmap can refine the query focal length in PnP+RANSAC. This is disabled by default.

sarlinpe commented 3 years ago

Closing this issue due to inactivity. Feel free to reopen it.

alexs7 commented 1 year ago

@Skydes Currently the only way to build a map with different intrinsics for each camera is to manually update the database ?

sarlinpe commented 1 year ago

You can force COLMAP to use different camera parameters for each image by changing the camera mode to PER_IMAGE:

python -m hloc.reconstruction [...] --camera_mode PER_IMAGE
model = reconstruction.main(..., camera_mode="PER_IMAGE")

You can also use the PER_FOLDER mode to share parameters among images that are in the same sub-folder. The modes are documented here.