1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
|
Frequently Asked Questions
==========================
Adjusting the options for different reconstruction scenarios and output quality
-------------------------------------------------------------------------------
COLMAP provides many options that can be tuned for different reconstruction
scenarios and to trade off accuracy and completeness versus efficiency. The
default options are set to for medium to high quality reconstruction of
unstructured input data. There are several presets for different scenarios and
quality levels, which can be set in the GUI as ``Extras > Set options for ...``.
To use these presets from the command-line, you can save the current set of
options as ``File > Save project`` after choosing the presets. The resulting
project file can be opened with a text editor to view the different options.
Extending COLMAP
----------------
If you need to simply analyze the produced sparse or dense reconstructions from
COLMAP, you can load the sparse models in Python and Matlab using the provided
scripts in ``scripts/python`` and ``scripts/matlab``.
If you want to write a C/C++ executable that builds on top of COLMAP, there are
two possible approaches. First, the COLMAP headers and library are installed
to the ``CMAKE_INSTALL_PREFIX`` by default. Compiling against COLMAP as a
library is described :ref:`here <installation-library>`. Alternatively, you can
start from the ``src/tools/example.cc`` code template and implement the desired
functionality directly as a new binary within COLMAP.
.. _faq-share-intrinsics:
Share intrinsics
----------------
COLMAP supports shared intrinsics for arbitrary groups of images and camera
models. Images share the same intrinsics, if they refer to the same camera, as
specified by the `camera_id` property in the database. You can add new cameras
and set shared intrinsics in the database management tool. Please, refer to
:ref:`Database Management <database-management>` for more information.
.. _faq-fix-intrinsics:
Fix intrinsics
--------------
By default, COLMAP tries to refine the intrinsic camera parameters (except
principal point) automatically during the reconstruction. Usually, if there are
enough images in the dataset and you share the intrinsics between multiple
images, the estimated intrinsic camera parameters in SfM should be better than
parameters manually obtained with a calibration pattern.
However, sometimes COLMAP's self-calibration routine might converge in
degenerate parameters, especially in case of the more complex camera models with
many distortion parameters. If you know the calibration parameters a priori, you
can fix different parameter groups during the reconstruction. Choose
``Reconstruction > Reconstruction options > Bundle Adj. > refine_*`` and check
which parameter group to refine or to keep constant. Even if you keep the
parameters constant during the reconstruction, you can refine the parameters in
a final global bundle adjustment by setting ``Reconstruction > Bundle adj.
options > refine_*`` and then running ``Reconstruction > Bundle adjustment``.
Principal point refinement
--------------------------
By default, COLMAP keeps the principal point constant during the reconstruction,
as principal point estimation is an ill-posed problem in general. Once all
images are reconstructed, the problem is most often constrained enough that you
can try to refine the principal point in global bundle adjustment, especially
when sharing intrinsic parameters between multiple images. Please, refer to
:ref:`Fix intrinsics <faq-fix-intrinsics>` for more information.
Increase number of matches / sparse 3D points
---------------------------------------------
To increase the number of matches, you should use the more discriminative
DSP-SIFT features instead of plain SIFT and also estimate the affine feature
shape using the options: ``--SiftExtraction.estimate_affine_shape=true`` and
``--SiftExtraction.domain_size_pooling=true``. In addition, you should enable
guided feature matching using: ``--SiftMatching.guided_matching=true``.
By default, COLMAP ignores two-view feature tracks in triangulation, resulting
in fewer 3D points than possible. Triangulation of two-view tracks can in rare
cases improve the stability of sparse image collections by providing additional
constraints in bundle adjustment. To also triangulate two-view tracks, unselect
the option ``Reconstruction > Reconstruction options > Triangulation >
ignore_two_view_tracks``. If your images are taken from far distance with
respect to the scene, you can try to reduce the minimum triangulation angle.
Reconstruct sparse/dense model from known camera poses
------------------------------------------------------
If the camera poses are known and you want to reconstruct a sparse or dense
model of the scene, you must first manually construct a sparse model by creating
a ``cameras.txt`` and ``images.txt`` file. The ``points3D.txt`` file should be
empty while every other line in the ``images.txt`` should also be empty, since
the sparse features are computed, as described below. You can refer to
:ref:`this article <output-format>` for more information about the structure of
a sparse model.
To reconstruct a sparse model, you first have to recompute features from the
images of the known camera poses as follows::
colmap feature_extractor \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images
If your known camera intrinsics have large distortion coefficients, you should
now manually copy the parameters from your ``cameras.txt`` to the database, such
that the matcher can leverage the intrinsics. Modifying the database is possible
in many ways, but an easy option is to use the provided
``scripts/python/database.py`` script. Otherwise, you can skip this step and
simply continue as follows::
colmap exhaustive_matcher \ # or alternatively any other matcher
--database_path $PROJECT_PATH/database.db
colmap point_triangulator \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images
--input_path path/to/manually/created/sparse/model \
--output_path path/to/triangulated/sparse/model
Note that the sparse reconstruction step is not necessary in order to compute
a dense model from known camera poses. Assuming you computed a sparse model
from the known camera poses, you can compute a dense model as follows::
colmap image_undistorter \
--image_path $PROJECT_PATH/images \
--input_path path/to/triangulated/sparse/model \
--output_path path/to/dense/workspace
colmap patch_match_stereo \
--workspace_path path/to/dense/workspace
colmap stereo_fusion \
--workspace_path path/to/dense/workspace \
--output_path path/to/dense/workspace/fused.ply
Alternatively, you can also produce a dense model without a sparse model as::
colmap image_undistorter \
--image_path $PROJECT_PATH/images \
--input_path path/to/manually/created/sparse/model \
--output_path path/to/dense/workspace
Since the sparse point cloud is used to automatically select neighboring images
during the dense stereo stage, you have to manually specify the source images,
as described :ref:`here <faq-dense-manual-source>`. The dense stereo stage
now also requires a manual specification of the depth range::
colmap patch_match_stereo \
--workspace_path path/to/dense/workspace \
--DenseStereo.depth_min $MIN_DEPTH \
--DenseStereo.depth_max $MAX_DEPTH
colmap stereo_fusion \
--workspace_path path/to/dense/workspace \
--output_path path/to/dense/workspace/fused.ply
.. _faq-merge-models:
Merge disconnected models
-------------------------
Sometimes COLMAP fails to reconstruct all images into the same model and hence
produces multiple sub-models. If those sub-models have common registered images,
they can be merged into a single model as post-processing step::
colmap model_merger \
--input_path1 /path/to/sub-model1 \
--input_path2 /path/to/sub-model2 \
--output_path /path/to/merged-model
To improve the quality of the alignment between the two sub-models, it is
recommended to run another global bundle adjustment after the merge::
colmap bundle_adjuster \
--input_path /path/to/merged-model \
--output_path /path/to/refined-merged-model
Geo-registration
----------------
Geo-registration of models is possible by providing the 3D locations for the
camera centers of a subset or all registered images. The 3D similarity
transformation between the reconstructed model and the target coordinate frame
of the geo-registration is determined from these correspondences.
The geo-registered 3D coordinates of the camera centers for images must be
specified in a text-file with the following format::
image_name1.jpg X1 Y1 Z1
image_name2.jpg X2 Y2 Z2
image_name3.jpg X3 Y3 Z3
...
Note that at least 3 images must be specified to estimate a 3D similarity
transformation. Then, the model can be geo-registered using::
colmap model_aligner \
--input_path /path/to/model \
--output_path /path/to/geo-registered-model \
--ref_images_path /path/to/text-file
Manhattan world alignment
-------------------------
COLMAP has functionality to align the coordinate axes of a reconstruction using
a Manhattan world assumption, i.e. COLMAP can automatically determine the
gravity axis and the major horizontal axis of the Manhattan world through
vanishing point detection in the images. Please, refer to the
``model_orientation_aligner`` for more details.
Register/localize new images into an existing reconstruction
------------------------------------------------------------
If you have an existing reconstruction of images and want to register/localize
new images within this reconstruction, you can follow these steps::
colmap feature_extractor \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images \
--image_list_path /path/to/image-list.txt
colmap vocab_tree_matcher \
--database_path $PROJECT_PATH/database.db \
--VocabTreeMatching.vocab_tree_path /path/to/vocab-tree.bin \
--VocabTreeMatching.match_list_path /path/to/image-list.txt
colmap image_registrator \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images \
--input_path /path/to/existing-model \
--output_path /path/to/model-with-new-images
colmap bundle_adjuster \
--input_path /path/to/model-with-new-images \
--output_path /path/to/model-with-new-images
Note that this first extracts features for the new images, then matches them to
the existing images in the database, and finally registers them into the model.
The image list text file contains a list of images to extract and match,
specified as one image file name per line. The bundle adjustment is optional.
If you need a more accurate image registration with triangulation, then you
should restart or continue the reconstruction process rather than just
registering the images to the model. Instead of running the
``image_registrator``, you should run the ``mapper`` to continue the
reconstruction process from the existing model::
colmap mapper \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images \
--input_path /path/to/existing-model \
--output_path /path/to/model-with-new-images
Or, alternatively, you can start the reconstruction from scratch::
colmap mapper \
--database_path $PROJECT_PATH/database.db \
--image_path $PROJECT_PATH/images \
--output_path /path/to/model-with-new-images
Note that dense reconstruction must be re-run from scratch after running the
``mapper`` or the ``bundle_adjuster``, as the coordinate frame of the model can
change during these steps.
Available functionality without GPU/CUDA
----------------------------------------
If you do not have a CUDA-enabled GPU but some other GPU, you can use all COLMAP
functionality except the dense reconstruction part. However, you can use
external dense reconstruction software as an alternative, as described in the
:ref:`Tutorial <dense-reconstruction>`. If you have a GPU with low compute power
or you want to execute COLMAP on a machine without an attached display and
without CUDA support, you can run all steps on the CPU by specifying the
appropriate options (e.g., ``--SiftExtraction.use_gpu=false`` for the feature
extraction step). But not that this might result in a significant slow-down of
the reconstruction pipeline.
Multi-GPU support in feature extraction/matching
------------------------------------------------
You can run feature extraction/matching on multiple GPUs by specifying multiple
indices for CUDA-enabled GPUs, e.g., ``--SiftExtraction.gpu_index=0,1,2,3`` and
``--SiftMatching.gpu_index=0,1,2,3`` runs the feature extraction/matching on 4
GPUs in parallel. Note that you can only run one thread per GPU and this
typically also gives the best performance. By default, COLMAP runs one feature
extraction/matching thread per CUDA-enabled GPU and this usually gives the best
performance as compared to running multiple threads on the same GPU.
Feature matching fails due to illegal memory access
---------------------------------------------------
If you encounter the following error message::
MultiplyDescriptor: an illegal memory access was encountered
or the following:
ERROR: Feature matching failed. This probably caused by insufficient GPU
memory. Consider reducing the maximum number of features.
during feature matching, your GPU runs out of memory. Try decreasing the option
``--SiftMatching.max_num_matches`` until the error disappears. Note that this
might lead to inferior feature matching results, since the lower-scale input
features will be clamped in order to fit them into GPU memory. Alternatively,
you could change to CPU-based feature matching, but this can become very slow,
or better you buy a GPU with more memory.
The maximum required GPU memory can be approximately estimated using the
following formula: ``4 * num_matches * num_matches + 4 * num_matches * 256``.
For example, if you set ``--SiftMatching.max_num_matches 10000``, the maximum
required GPU memory will be around 400MB, which are only allocated if one of
your images actually has that many features.
Trading off completeness and accuracy in dense reconstruction
-------------------------------------------------------------
If the dense point cloud contains too many outliers and too much noise, try to
increase the value of option ``--StereoFusion.min_num_pixels``.
If the reconstructed dense surface mesh model using Poisson reconstruction
contains no surface or there are too many outlier surfaces, you should reduce
the value of option ``--PoissonMeshing.trim`` to decrease the surface are and
vice versa to increase it. Also consider to try the reduce the outliers or
increase the completeness in the fusion stage, as described above.
If the reconstructed dense surface mesh model using Delaunay reconstruction
contains too noisy or incomplete surfaces, you should increase the
``--DenaunayMeshing.quality_regularization`` parameter to obtain a smoother
surface. If the resolution of the mesh is too coarse, you should reduce the
``--DelaunayMeshing.max_proj_dist`` option to a lower value.
Improving dense reconstruction results for weakly textured surfaces
-------------------------------------------------------------------
For scenes with weakly textured surfaces it can help to have a high resolution
of the input images (``--DenseStereo.max_image_size``) and a large patch window
radius (``--DenseStereo.window_radius``). You may also want to reduce the
filtering threshold for the photometric consistency cost
(``--DenseStereo.filter_min_ncc``).
Surface mesh reconstruction
---------------------------
COLMAP supports two types of surface reconstruction algorithms. Poisson surface
reconstruction [kazhdan2013]_ and graph-cut based surface extraction from a
Delaunay triangulation. Poisson surface reconstruction typically requires an
almost outlier-free input point cloud and it often produces bad surfaces in the
presence of outliers or large holes in the input data. The Delaunay
triangulation based meshing algorithm is more robust to outliers and in general
more scalable to large datasets than the Poisson algorithm, but it usually
produces less smooth surfaces. Furthermore, the Delaunay based meshing can be
applied to sparse and dense reconstruction results. To increase the smoothness
of the surface as a post-processing step, you could use Laplacian smoothing, as
e.g. implemented in Meshlab.
Note that the two algorithms can also be combined by first running the Delaunay
meshing to robustly filter outliers from the sparse or dense point cloud and
then, in the second step, performing Poisson surface reconstruction to obtain a
smooth surface.
Speedup dense reconstruction
----------------------------
The dense reconstruction can be speeded up in multiple ways:
- Put more GPUs in your system as the dense reconstruction can make use of
multiple GPUs during the stereo reconstruction step. Put more RAM into your
system and increase the ``--DenseStereo.cache_size``,
``--StereoFusion.cache_size`` to the largest possible value in order to
speed up the dense fusion step.
- Do not perform geometric dense stereo reconstruction
``--DenseStereo.geom_consistency false``. Make sure to also enable
``--DenseStereo.filter true`` in this case.
- Reduce the ``--DenseStereo.max_image_size``, ``--StereoFusion.max_image_size``
values to perform dense reconstruction on a maximum image resolution.
- Reduce the number of source images per reference image to be considered, as
described :ref:`here <faq-dense-memory>`.
- Increase the patch windows step ``--DenseStereo.window_step`` to 2.
- Reduce the patch window radius ``--DenseStereo.window_radius``.
- Reduce the number of patch match iterations ``--DenseStereo.num_iterations``.
- Reduce the number of sampled views ``--DenseStereo.num_samples``.
- To speedup the dense stereo and fusion step for very large reconstructions,
you can use CMVS to partition your scene into multiple clusters and to prune
redundant images, as described :ref:`here <faq-dense-memory>`.
Note that apart from upgrading your hardware, the proposed changes might degrade
the quality of the dense reconstruction results. When canceling the stereo
reconstruction process and restarting it later, the previous progress is not
lost and any already processed views will be skipped.
.. _faq-dense-memory:
Reduce memory usage during dense reconstruction
-----------------------------------------------
If you run out of GPU memory during patch match stereo, you can either reduce
the maximum image size by setting the option ``--DenseStereo.max_image_size`` or
reduce the number of source images in the ``stereo/patch-match.cfg`` file from
e.g. ``__auto__, 30`` to ``__auto__, 10``. Note that enabling the
``geom_consistency`` option increases the required GPU memory.
If you run out of CPU memory during stereo or fusion, you can reduce the
``--DenseStereo.cache_size`` or ``--StereoFusion.cache_size`` specified in
gigabytes or you can reduce ``--DenseStereo.max_image_size`` or
``--StereoFusion.max_image_size``. Note that a too low value might lead to very
slow processing and heavy load on the hard disk.
For large-scale reconstructions of several thousands of images, you should
consider splitting your sparse reconstruction into more manageable clusters of
images using e.g. CMVS [furukawa10]_. In addition, CMVS allows to prune
redundant images observing the same scene elements. Note that, for this use
case, COLMAP's dense reconstruction pipeline also supports the PMVS/CMVS folder
structure when executed from the command-line. Please, refer to the workspace
folder for example shell scripts. Note that the example shell scripts for
PMVS/CMVS are only generated, if the output type is set to PMVS. Since CMVS
produces highly overlapping clusters, it is recommended to increase the default
value of 100 images per cluster to as high as possible according to your
available system resources and speed requirements. To change the number of
images using CMVS, you must modify the shell scripts accordingly. For example,
``cmvs pmvs/ 500`` to limit each cluster to 500 images. If you want to use CMVS
to prune redundant images but not to cluster the scene, you can simply set this
number to a very large value.
.. _faq-dense-manual-source:
Manual specification of source images during dense reconstruction
-----------------------------------------------------------------
You can change the number of source images in the ``stereo/patch-match.cfg``
file from e.g. ``__auto__, 30`` to ``__auto__, 10``. This selects the images
with the most visual overlap automatically as source images. You can also use
all other images as source images, by specifying ``__all__``. Alternatively, you
can manually specify images with their name, for example::
image1.jpg
image2.jpg, image3.jpg
image2.jpg
image1.jpg, image3.jpg
image3.jpg
image1.jpg, image2.jpg
Here, ``image2.jpg`` and ``image3.jpg`` are used as source images for
``image1.jpg``, etc.
Multi-GPU support in dense reconstruction
-----------------------------------------
You can run dense reconstruction on multiple GPUs by specifying multiple indices
for CUDA-enabled GPUs, e.g., ``--DenseStereo.gpu_index=0,1,2,3`` runs the dense
reconstruction on 4 GPUs in parallel. You can also run multiple dense
reconstruction threads on the same GPU by specifying the same GPU index twice,
e.g., ``--DenseStereo.gpu_index=0,0,1,1,2,3``. By default, COLMAP runs one
dense reconstruction thread per CUDA-enabled GPU.
.. _faq-dense-timeout:
Fix GPU freezes and timeouts during dense reconstruction
--------------------------------------------------------
The stereo reconstruction pipeline runs on the GPU using CUDA and puts the GPU
under heavy load. You might experience a display freeze or even a program crash
during the reconstruction. As a solution to this problem, you could use a
secondary GPU in your system, that is not connected to your display by setting
the GPU indices explicitly (usually index 0 corresponds to the card that the
display is attached to). Alternatively, you can increase the GPU timeouts of
your system, as detailed in the following.
By default, the Windows operating system detects response problems from the GPU,
and recovers to a functional desktop by resetting the card and aborting the
stereo reconstruction process. The solution is to increase the so-called
"Timeout Detection & Recovery" (TDR) delay to a larger value. Please, refer to
the `NVIDIA Nsight documentation <https://goo.gl/UWKVs6>`_ or to the `Microsoft
documentation <http://www.microsoft.com/whdc/device/display/wddm_timeout.mspx>`_
on how to increase the delay time under Windows. You can increase the delay
using the following Windows Registry entries::
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers]
"TdrLevel"=dword:00000001
"TdrDelay"=dword:00000120
To set the registry entries, execute the following commands using administrator
privileges (e.g., in ``cmd.exe`` or ``powershell.exe``)::
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers /v TdrLevel /t REG_DWORD /d 00000001
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers /v TdrDelay /t REG_DWORD /d 00000120
and restart your machine afterwards to make the changes effective.
The X window system under Linux/Unix has a similar feature and detects response
problems of the GPU. The easiest solution to avoid timeout problems under the X
window system is to shut it down and run the stereo reconstruction from the
command-line. Under Ubuntu, you could first stop X using::
sudo service lightdm stop
And then run the dense reconstruction code from the command-line::
colmap patch_match_stereo ...
Finally, you can restart your desktop environment with the following command::
sudo service lightdm start
If the dense reconstruction still crashes after these changes, the reason is
probably insufficient GPU memory, as discussed in a separate item in this list.
|