| 1 |
.. _tutorial: |
| 2 |
|
| 3 |
Tutorial |
| 4 |
======== |
| 5 |
|
| 6 |
This tutorial covers the topic of image-based 3D reconstruction by demonstrating |
| 7 |
the individual processing steps in COLMAP. If you are interested in a more |
| 8 |
general and mathematical introduction to the topic of image-based 3D |
| 9 |
reconstruction, please also refer to the `CVPR 2017 Tutorial on Large-scale 3D |
| 10 |
Modeling from Crowdsourced Data <https://demuc.de/tutorials/cvpr2017/>`_ and |
| 11 |
[schoenberger_thesis]_. |
| 12 |
|
| 13 |
Image-based 3D reconstruction from images traditionally first recovers a sparse |
| 14 |
representation of the scene and the camera poses of the input images using |
| 15 |
Structure-from-Motion. This output then serves as the input to Multi-View Stereo |
| 16 |
to recover a dense representation of the scene. |
| 17 |
|
| 18 |
.. contents:: Contents |
| 19 |
:local: |
| 20 |
:depth: 1 |
| 21 |
|
| 22 |
|
| 23 |
.. _quick-start: |
| 24 |
|
| 25 |
Quickstart |
| 26 |
---------- |
| 27 |
|
| 28 |
First, start the graphical user interface of COLMAP, as described :ref:`here |
| 29 |
<gui>`. COLMAP provides an automatic reconstruction tool that simply takes |
| 30 |
a folder of input images and produces a sparse and dense reconstruction in a |
| 31 |
workspace folder. Click ``Reconstruction > Automatic Reconstruction`` in the GUI |
| 32 |
and specify the relevant options. The output is written to the workspace folder. |
| 33 |
For example, if your images are located in ``path/to/project/images``, you could |
| 34 |
select ``path/to/project`` as a workspace folder and after running the automatic |
| 35 |
reconstruction tool, the folder would look similar to this:: |
| 36 |
|
| 37 |
+── images |
| 38 |
│ +── image1.jpg |
| 39 |
│ +── image2.jpg |
| 40 |
│ +── ... |
| 41 |
+── sparse |
| 42 |
│ +── 0 |
| 43 |
│ │ +── rigs.bin |
| 44 |
│ │ +── cameras.bin |
| 45 |
│ │ +── frames.bin |
| 46 |
│ │ +── images.bin |
| 47 |
│ │ +── points3D.bin |
| 48 |
│ +── ... |
| 49 |
+── dense |
| 50 |
│ +── 0 |
| 51 |
│ │ +── images |
| 52 |
│ │ +── sparse |
| 53 |
│ │ +── stereo |
| 54 |
│ │ +── fused.ply |
| 55 |
│ │ +── meshed-poisson.ply |
| 56 |
│ │ +── meshed-delaunay.ply |
| 57 |
│ │ +── meshed-advancing-front.ply |
| 58 |
│ +── ... |
| 59 |
+── database.db |
| 60 |
|
| 61 |
Here, the ``path/to/project/sparse`` contains the sparse models for all |
| 62 |
reconstructed components, while ``path/to/project/dense`` contains their |
| 63 |
corresponding dense models. The dense point cloud ``fused.ply`` can be imported |
| 64 |
in COLMAP using ``File > Import from ...``, while the dense mesh must be |
| 65 |
visualized with an external viewer such as Meshlab. |
| 66 |
|
| 67 |
The same automatic reconstruction can be run from the command-line, without the |
| 68 |
GUI, using the ``automatic_reconstructor`` command, which produces the identical |
| 69 |
workspace layout shown above:: |
| 70 |
|
| 71 |
colmap automatic_reconstructor \\ |
| 72 |
--workspace_path path/to/project \\ |
| 73 |
--image_path path/to/project/images |
| 74 |
|
| 75 |
The following sections give general recommendations and describe the |
| 76 |
reconstruction process in more detail, if you need more control over the |
| 77 |
reconstruction process/parameters or if you are interested in the underlying |
| 78 |
technology in COLMAP. |
| 79 |
|
| 80 |
|
| 81 |
Preface |
| 82 |
------- |
| 83 |
|
| 84 |
COLMAP requires only a few steps to perform a standard reconstruction for a |
| 85 |
general user. For more experienced users, the program exposes many different parameters, |
| 86 |
only some of which are intuitive to a beginner. The program should usually work |
| 87 |
without the need to modify any parameters. The defaults are chosen as a trade- |
| 88 |
off between reconstruction robustness/quality and speed. You can set "optimal" |
| 89 |
options for different reconstruction scenarios by choosing ``Extras > Set |
| 90 |
options for ... data``. If in doubt what settings to choose, stick to the |
| 91 |
defaults. The source code contains more documentation about all parameters. |
| 92 |
|
| 93 |
COLMAP is research software, and in rare cases it may exit ungracefully if some |
| 94 |
constraints are not fulfilled. In this case, the program prints a traceback to |
| 95 |
stderr. To see this traceback or more debug information, it is recommended to |
| 96 |
run the executables (including the GUI) from the command-line, where you can |
| 97 |
also define various levels of logging verbosity. |
| 98 |
|
| 99 |
|
| 100 |
Structure-from-Motion |
| 101 |
--------------------- |
| 102 |
|
| 103 |
.. figure:: images/incremental-sfm.webp |
| 104 |
:alt: Incremental Structure-from-Motion pipeline |
| 105 |
:figclass: align-center |
| 106 |
|
| 107 |
COLMAP's incremental Structure-from-Motion pipeline. |
| 108 |
|
| 109 |
Structure-from-Motion (SfM) is the process of reconstructing 3D structure from |
| 110 |
its projections into a series of images. The input is a set of overlapping |
| 111 |
images of the same object, taken from different viewpoints. The output is a 3-D |
| 112 |
reconstruction of the object, and the reconstructed intrinsic and extrinsic |
| 113 |
camera parameters of all images. Typically, Structure-from-Motion systems divide |
| 114 |
this process into three stages: |
| 115 |
|
| 116 |
1) Feature detection and extraction |
| 117 |
2) Feature matching and geometric verification |
| 118 |
3) Structure and motion reconstruction |
| 119 |
|
| 120 |
COLMAP reflects these stages in different modules that can be combined |
| 121 |
depending on the application. More information on Structure-from-Motion in |
| 122 |
general and the algorithms in COLMAP can be found in [schoenberger16sfm]_ and |
| 123 |
[schoenberger16mvs]_. |
| 124 |
|
| 125 |
If you have control over the picture capture process, please follow these |
| 126 |
guidelines for optimal reconstruction results: |
| 127 |
|
| 128 |
- Capture images with **good texture**. Avoid completely texture-less images |
| 129 |
(e.g., a white wall or empty desk). If the scene does not contain enough |
| 130 |
texture itself, you could place additional background objects, such as |
| 131 |
posters, etc. |
| 132 |
|
| 133 |
- Capture images at **similar illumination** conditions. Avoid high dynamic |
| 134 |
range scenes (e.g., pictures against the sun with shadows or pictures |
| 135 |
through doors/windows). Avoid specularities on shiny surfaces. |
| 136 |
|
| 137 |
- Capture images with **high visual overlap**. Make sure that each object is |
| 138 |
seen in at least 3 images -- the more images the better. |
| 139 |
|
| 140 |
- Capture images from **different viewpoints**. Do not take images from the |
| 141 |
same location by only rotating the camera, e.g., make a few steps after each |
| 142 |
shot. At the same time, try to have enough images from a relatively similar |
| 143 |
viewpoint. Note that more images are not necessarily better and might lead to a |
| 144 |
slow reconstruction process. If you use a video as input, consider |
| 145 |
down-sampling the frame rate. |
| 146 |
|
| 147 |
|
| 148 |
Multi-View Stereo |
| 149 |
----------------- |
| 150 |
|
| 151 |
Multi-View Stereo (MVS) takes the output of SfM to compute depth and/or normal |
| 152 |
information for every pixel in an image. Fusion of the depth and normal maps of |
| 153 |
multiple images in 3D then produces a dense point cloud of the scene. Using the |
| 154 |
depth and normal information of the fused point cloud, algorithms such as the |
| 155 |
(screened) Poisson surface reconstruction [kazhdan2013]_ or the advancing front |
| 156 |
surface reconstruction [cohen-steiner2004]_ can then recover the 3D surface |
| 157 |
geometry of the scene. The resulting meshes can optionally be simplified |
| 158 |
using Quadric Error Metric (QEM) decimation [garland1997]_ to reduce their |
| 159 |
complexity while preserving shape and appearance. Additionally, the meshes can |
| 160 |
be textured using multi-view texture mapping [waechter2014]_, which assigns each |
| 161 |
face to the best-view camera image and produces a texture atlas with UV |
| 162 |
coordinates. More information on Multi-View Stereo in general and the algorithms |
| 163 |
in COLMAP can be found in [schoenberger16mvs]_. |
| 164 |
|
| 165 |
|
| 166 |
Terminology |
| 167 |
----------- |
| 168 |
|
| 169 |
The term **camera** refers to a physical camera using the same zoom factor and |
| 170 |
lens. A camera defines the intrinsic projection model in |
| 171 |
COLMAP. A single camera can take multiple images with the same resolution, |
| 172 |
intrinsic parameters, and distortion characteristics. The term **image** is |
| 173 |
associated with a bitmap file, e.g., a JPEG or PNG file on disk. COLMAP detects |
| 174 |
**keypoints** in each image whose appearance is described by numerical |
| 175 |
**descriptors**. Pure appearance-based correspondences between |
| 176 |
keypoints/descriptors are defined by **matches**, while **inlier matches** are |
| 177 |
geometrically verified and used for the reconstruction procedure. |
| 178 |
|
| 179 |
The term **rig** describes a fixed assembly of one or more cameras whose relative |
| 180 |
poses are constant over time, e.g., a stereo or multi-camera setup, or a single |
| 181 |
moving camera (a trivial rig with one camera). The term **frame** denotes a |
| 182 |
single snapshot in time, i.e., the set of images captured simultaneously by all |
| 183 |
cameras of a rig. A frame therefore groups images that share the same rig pose, |
| 184 |
and COLMAP optimizes one pose per frame rather than one pose per image. Rigs and |
| 185 |
frames are stored as ``rigs.bin`` and ``frames.bin`` in the reconstruction output |
| 186 |
(see :ref:`Rig Support <rig-support>` and :ref:`Output Format <output-format>`). |
| 187 |
|
| 188 |
|
| 189 |
Data Structure |
| 190 |
-------------- |
| 191 |
|
| 192 |
COLMAP assumes that all input images are in one input directory with potentially |
| 193 |
nested sub-directories. It recursively considers all images stored in this |
| 194 |
directory, and it supports various image formats through OpenImageIO. Other |
| 195 |
files are automatically ignored. If high performance is a requirement, then you |
| 196 |
should separate any files that are not images. Images are identified uniquely by |
| 197 |
their relative file path. For later processing, such as image undistortion or |
| 198 |
dense reconstruction, the relative folder structure should be preserved. COLMAP |
| 199 |
does not modify the input images or directory and all extracted data is stored |
| 200 |
in a single, self-contained SQLite database file (see :doc:`database`). |
| 201 |
|
| 202 |
The first step is to start the graphical user interface of COLMAP by running the |
| 203 |
pre-built binaries (Windows: ``COLMAP.bat``, Mac: ``COLMAP.app``) or by executing |
| 204 |
``./src/colmap/exe/colmap gui`` from the CMake build folder. Next, create a new project |
| 205 |
by choosing ``File > New project``. In this dialog, you must select where to |
| 206 |
store the database and the folder that contains the input images. For |
| 207 |
convenience, you can save the entire project settings to a configuration file by |
| 208 |
choosing ``File > Save project``. The project configuration stores the absolute |
| 209 |
path information of the database and image folder in addition to any other |
| 210 |
parameter settings. If you decide to move the database or image folder, you must |
| 211 |
change the paths accordingly by creating a new project. Alternatively, the |
| 212 |
resulting ``.ini`` configuration file can be directly modified in a text editor of |
| 213 |
your choice. To reopen an existing project, you can simply open the |
| 214 |
configuration file by choosing ``File > Open project`` and all parameter |
| 215 |
settings should be recovered. Note that all COLMAP executables can be started |
| 216 |
from the command-line by either specifying individual settings as command-line |
| 217 |
arguments or by providing the path to the project configuration file (see |
| 218 |
:ref:`Interface <interface>`). |
| 219 |
|
| 220 |
An example folder structure could look like this:: |
| 221 |
|
| 222 |
/path/to/project/... |
| 223 |
+── images |
| 224 |
│ +── image1.jpg |
| 225 |
│ +── image2.jpg |
| 226 |
│ +── ... |
| 227 |
│ +── imageN.jpg |
| 228 |
+── database.db |
| 229 |
+── project.ini |
| 230 |
|
| 231 |
In this example, you would select ``/path/to/project/images`` as the image folder |
| 232 |
path, ``/path/to/project/database.db`` as the database file path, and save the |
| 233 |
project configuration to ``/path/to/project/project.ini``. |
| 234 |
|
| 235 |
|
| 236 |
Feature Detection and Extraction |
| 237 |
-------------------------------- |
| 238 |
|
| 239 |
In the first step, feature detection/extraction finds sparse feature points in |
| 240 |
the image and describes their appearance using a numerical descriptor. COLMAP |
| 241 |
imports images and performs feature detection/extraction in a single step, so |
| 242 |
that each image is loaded from disk only once. |
| 243 |
|
| 244 |
Next, choose ``Processing > Extract features``. In this dialog, you must first |
| 245 |
decide on the intrinsic camera model to use. You can either automatically |
| 246 |
extract focal length information from the embedded EXIF information or manually |
| 247 |
specify intrinsic parameters, e.g., as obtained in a lab calibration. If an |
| 248 |
image has partial EXIF information, COLMAP tries to find the missing camera |
| 249 |
specifications in a large database of camera models automatically. If all your |
| 250 |
images were captured by the same physical camera with identical zoom factor, it |
| 251 |
is recommended to share intrinsics between all images. Note that the program |
| 252 |
will exit ungracefully if the same camera model is shared among all images but |
| 253 |
not all images have the same size or EXIF focal length. If you have several |
| 254 |
groups of images that share the same intrinsic camera parameters, you can easily |
| 255 |
modify the camera models at a later point as well (see :ref:`Database Management |
| 256 |
<database-management>`). If in doubt what to choose in this step, simply stick |
| 257 |
to the default parameters. |
| 258 |
|
| 259 |
You can either detect and extract new features from the images or import |
| 260 |
existing features from text files. By default, COLMAP extracts SIFT [lowe04]_ |
| 261 |
features either on the GPU or the CPU. When COLMAP is built with CUDA support |
| 262 |
(recommended), GPU feature extraction runs without an attached display and is |
| 263 |
suitable for headless servers. The OpenGL-based fallback (used when CUDA is not |
| 264 |
available) instead requires an attached display, so on such systems the CPU |
| 265 |
version is recommended for use on a server. In general, the GPU version is |
| 266 |
favorable, as it has a customized feature detection mode that often produces |
| 267 |
higher-quality features for high-contrast images. |
| 268 |
COLMAP also supports ALIKED and LoMa feature extraction, learned feature |
| 269 |
extractors using ONNX models, which can be selected via the |
| 270 |
``--FeatureExtraction.type`` option (see |
| 271 |
:ref:`Feature Extraction and Matching <features>` for details). If |
| 272 |
you import existing features, every image must have a text file next to it (e.g., |
| 273 |
``/path/to/image1.jpg`` and ``/path/to/image1.jpg.txt``) in the following format:: |
| 274 |
|
| 275 |
NUM_FEATURES 128 |
| 276 |
X Y SCALE ORIENTATION D_1 D_2 D_3 ... D_128 |
| 277 |
... |
| 278 |
X Y SCALE ORIENTATION D_1 D_2 D_3 ... D_128 |
| 279 |
|
| 280 |
where ``X, Y, SCALE, ORIENTATION`` are floating point numbers and ``D_1...D_128`` |
| 281 |
values in the range ``0...255``. The file should have ``NUM_FEATURES`` lines with |
| 282 |
one line per feature. For example, if an image has 4 features, then the text |
| 283 |
file should look something like this:: |
| 284 |
|
| 285 |
4 128 |
| 286 |
1.2 2.3 0.1 0.3 1 2 3 4 ... 21 |
| 287 |
2.2 3.3 1.1 0.3 3 2 3 2 ... 32 |
| 288 |
0.2 1.3 1.1 0.3 3 2 3 2 ... 2 |
| 289 |
1.2 2.3 1.1 0.3 3 2 3 2 ... 3 |
| 290 |
|
| 291 |
Note that by convention the upper left corner of an image has coordinate |
| 292 |
``(0, 0)`` and the center of the upper left most pixel has coordinate |
| 293 |
``(0.5, 0.5)``. If you must import features for large image collections, it is |
| 294 |
much more efficient to directly access the database with your favorite scripting |
| 295 |
language (see |
| 296 |
:ref:`Database Format <database-format>`). |
| 297 |
|
| 298 |
If you are done setting all options, choose ``Extract`` and wait for the |
| 299 |
extraction to finish or cancel. If you cancel during the extraction process, the |
| 300 |
next time you start extracting images for the same project, COLMAP automatically |
| 301 |
continues where it left off. This also allows you to add images to an existing |
| 302 |
project/reconstruction. In this case, be sure to verify the camera parameters |
| 303 |
when using shared intrinsics. |
| 304 |
|
| 305 |
All extracted data will be stored in the database file and can be |
| 306 |
reviewed/managed in the database management tool (see :ref:`Database Management |
| 307 |
<database-management>`) or, for experts, directly modified using SQLite (see |
| 308 |
:ref:`Database Format <database-format>`). |
| 309 |
|
| 310 |
|
| 311 |
Feature Matching and Geometric Verification |
| 312 |
------------------------------------------- |
| 313 |
|
| 314 |
In the second step, feature matching and geometric verification finds |
| 315 |
correspondences between the feature points in different images. |
| 316 |
|
| 317 |
Please choose ``Processing > Feature matching`` and select one of the provided |
| 318 |
matching modes, which are intended for different input scenarios: |
| 319 |
|
| 320 |
- **Exhaustive Matching**: If the number of images in your dataset is |
| 321 |
relatively low (up to several hundreds), this matching mode should be fast |
| 322 |
enough and lead to the best reconstruction results. Here, every image is |
| 323 |
matched against every other image, while the block size determines how many |
| 324 |
images are loaded from disk into memory at the same time. |
| 325 |
|
| 326 |
- **Sequential Matching**: This mode is useful if the images are acquired in |
| 327 |
sequential order, e.g., by a video camera. In this case, consecutive frames |
| 328 |
have visual overlap and there is no need to match all image pairs |
| 329 |
exhaustively. Instead, consecutively captured images are matched against each |
| 330 |
other. This matching mode has built-in loop detection based on a vocabulary |
| 331 |
tree, where every N-th image (``--SequentialMatching.loop_detection_period``) |
| 332 |
is matched against its visually most similar images |
| 333 |
(``--SequentialMatching.loop_detection_num_images``). Retrieved images can |
| 334 |
be restricted to those that are sufficiently far from the query in the |
| 335 |
sequence (``--SequentialMatching.loop_detection_min_index_distance``), so |
| 336 |
that nearby images do not consume the loop detection budget. A value of zero |
| 337 |
disables this restriction. Note that image file names must be ordered |
| 338 |
sequentially (e.g., ``image0001.jpg``, |
| 339 |
``image0002.jpg``, etc.). The order in the database is not relevant, since the |
| 340 |
images are explicitly ordered according to their file names. Note that loop |
| 341 |
detection requires a pre-trained vocabulary tree. A default tree will be |
| 342 |
automatically downloaded and cached. More trees are available and can be |
| 343 |
downloaded from https://demuc.de/colmap/. In case rigs and frames are |
| 344 |
configured appropriately in the database, sequential matching will |
| 345 |
automatically match all images in consecutive frames against each other. |
| 346 |
|
| 347 |
- **Vocabulary Tree Matching**: In this matching mode [schoenberger16vote]_, |
| 348 |
every image is matched against its visual nearest neighbors using a vocabulary |
| 349 |
tree with spatial re-ranking. This is the recommended matching mode for large |
| 350 |
image collections (several thousands). This requires a pre-trained vocabulary |
| 351 |
tree, that can be downloaded from https://demuc.de/colmap/. |
| 352 |
|
| 353 |
- **Spatial Matching**: This matching mode matches every image against its |
| 354 |
spatial nearest neighbors. Spatial locations can be manually set in the |
| 355 |
database management. By default, COLMAP also extracts GPS information from |
| 356 |
EXIF and uses it for spatial nearest neighbor search. If accurate prior |
| 357 |
location information is available, this is the recommended matching mode. |
| 358 |
|
| 359 |
- **Transitive Matching**: This matching mode uses the transitive relations of |
| 360 |
already existing feature matches to produce a more complete matching graph. |
| 361 |
If an image A matches to an image B and B matches to C, then this matcher |
| 362 |
attempts to match A to C directly. |
| 363 |
|
| 364 |
- **Custom Matching**: This mode allows you to specify individual image pairs for |
| 365 |
matching or to import individual feature matches. To specify image pairs, you |
| 366 |
have to provide a text file with one image pair per line:: |
| 367 |
|
| 368 |
image1.jpg image2.jpg |
| 369 |
image1.jpg image3.jpg |
| 370 |
... |
| 371 |
|
| 372 |
where ``image1.jpg`` is the relative path in the image folder. You have two |
| 373 |
options for importing individual feature matches: either raw feature matches, |
| 374 |
which are not geometrically verified, or already geometrically verified feature |
| 375 |
matches. In both cases, the expected format is:: |
| 376 |
|
| 377 |
image1.jpg image2.jpg |
| 378 |
0 1 |
| 379 |
1 2 |
| 380 |
3 4 |
| 381 |
<empty-line> |
| 382 |
image1.jpg image3.jpg |
| 383 |
0 1 |
| 384 |
1 2 |
| 385 |
3 4 |
| 386 |
4 5 |
| 387 |
<empty-line> |
| 388 |
... |
| 389 |
|
| 390 |
where ``image1.jpg`` is the relative path in the image folder and the pairs of |
| 391 |
numbers are zero-based feature indices in the respective images. If you must |
| 392 |
import many matches for large image collections, it is more efficient to |
| 393 |
directly access the database with a scripting language of your choice. |
| 394 |
|
| 395 |
If you are done setting all options, choose ``Match`` and wait for the matching |
| 396 |
to finish or cancel in between. Note that this step can take a significant |
| 397 |
amount of time depending on the number of images, the number of features per |
| 398 |
image, and the chosen matching mode. Expected times for exhaustive matching are |
| 399 |
from a few minutes for tens of images to a few hours for hundreds of images to |
| 400 |
days or weeks for thousands of images. Exhaustive matching scales quadratically |
| 401 |
with the number of images and quickly becomes impractical for large collections; |
| 402 |
for thousands of images or more, use vocabulary tree or sequential matching |
| 403 |
instead, which are dramatically faster. If you cancel the matching process or |
| 404 |
import new images after matching, COLMAP only matches image pairs that have not |
| 405 |
been matched previously. The overhead of skipping already matched image pairs is |
| 406 |
low. This also makes it possible to match additional images imported after an |
| 407 |
initial matching, and to combine different matching modes for the same dataset. |
| 408 |
|
| 409 |
All extracted data will be stored in the database file and can be |
| 410 |
reviewed/managed in the database management tool (see :ref:`Database Management |
| 411 |
<database-management>`) or, for experts, directly modified using SQLite (see |
| 412 |
:ref:`Database Format <database-format>`). |
| 413 |
|
| 414 |
Note that SIFT feature matching can use a GPU for acceleration, and the display |
| 415 |
performance of your computer might degrade significantly during the matching |
| 416 |
process. If your system has multiple CUDA-enabled GPUs, you can select specific |
| 417 |
GPUs with the ``--FeatureMatching.gpu_index`` option. Feature matching can also |
| 418 |
be performed on the CPU by setting ``--FeatureMatching.use_gpu 0``, although this |
| 419 |
will be significantly slower for large datasets. |
| 420 |
|
| 421 |
|
| 422 |
Sparse Reconstruction |
| 423 |
--------------------- |
| 424 |
|
| 425 |
After producing the scene graph in the previous two steps, you can start the |
| 426 |
incremental reconstruction process by choosing ``Reconstruction > Start``. |
| 427 |
COLMAP first loads all extracted data from the database into memory and seeds |
| 428 |
the reconstruction from an initial image pair. Then, the scene is incrementally |
| 429 |
extended by registering new images and triangulating new points. The results are |
| 430 |
visualized in "real-time" during this reconstruction process. Refer to the |
| 431 |
:ref:`Graphical User Interface <gui>` section for more details about the |
| 432 |
available controls. COLMAP attempts to reconstruct multiple models if not all |
| 433 |
images are registered into the same model. The different models can be selected |
| 434 |
from the drop-down menu in the toolbar. If the different models have common |
| 435 |
registered images, you can use the ``model_merger`` executable to merge them |
| 436 |
into a single reconstruction (see :ref:`FAQ <faq-merge-models>` for details). |
| 437 |
|
| 438 |
Ideally, the reconstruction works fine and all images are registered. If this is |
| 439 |
not the case, it is recommended to: |
| 440 |
|
| 441 |
- Perform additional matching. For best results, use exhaustive matching, enable |
| 442 |
guided matching, increase the number of nearest neighbors in vocabulary tree |
| 443 |
matching, or increase the overlap in sequential matching, etc. |
| 444 |
|
| 445 |
- Manually choose an initial image pair, if COLMAP fails to initialize. Choose |
| 446 |
``Reconstruction > Reconstruction options > Init`` and set images from the |
| 447 |
database management tool that have enough matches from different viewpoints. |
| 448 |
|
| 449 |
|
| 450 |
Importing and Exporting |
| 451 |
----------------------- |
| 452 |
|
| 453 |
COLMAP provides several export options for further processing. For full |
| 454 |
flexibility, it is recommended to export the reconstruction in COLMAP's data |
| 455 |
format by choosing ``File > Export model`` to export the currently viewed model |
| 456 |
or ``File > Export all models`` to export all reconstructed models. The model is |
| 457 |
exported in the selected folder using separate text files for the reconstructed |
| 458 |
cameras, images, and points. When exporting in COLMAP's data format, you can |
| 459 |
re-import the reconstruction for later visualization, image undistortion, or to |
| 460 |
continue an existing reconstruction from where it left off (e.g., after importing |
| 461 |
and matching new images). To import a model, choose ``File > Import model`` and |
| 462 |
select the export folder path. Alternatively, you can export the model in |
| 463 |
various other formats, such as Bundler, VisualSfM [#f1]_, PLY, or VRML by |
| 464 |
choosing ``File > Export model as...``. COLMAP can visualize plain PLY point |
| 465 |
cloud files with RGB information by choosing ``File > Import from ...``. Further |
| 466 |
information about the format of the exported models can be found |
| 467 |
:ref:`here <output-format>`. |
| 468 |
|
| 469 |
|
| 470 |
.. _dense-reconstruction: |
| 471 |
|
| 472 |
Dense Reconstruction |
| 473 |
-------------------- |
| 474 |
|
| 475 |
After reconstructing a sparse representation of the scene and the camera poses |
| 476 |
of the input images, MVS can now recover denser scene geometry. COLMAP has an |
| 477 |
integrated dense reconstruction pipeline to produce depth and normal maps for |
| 478 |
all registered images, to fuse the depth and normal maps into a dense point |
| 479 |
cloud with normal information, and to finally estimate a dense surface from the |
| 480 |
fused point cloud using Poisson [kazhdan2013]_ or Delaunay reconstruction. |
| 481 |
Optionally, the resulting meshes can be simplified using the ``mesh_simplifier`` |
| 482 |
command to reduce the number of faces while preserving the overall shape. The |
| 483 |
meshes can also be textured using the ``mesh_texturer`` command, which produces |
| 484 |
a texture atlas and per-face UV coordinates from the undistorted images. |
| 485 |
|
| 486 |
To get started, import your sparse 3D model into COLMAP (or select the |
| 487 |
reconstructed model after finishing the previous sparse reconstruction steps). |
| 488 |
Then, choose ``Reconstruction > Multi-view stereo`` and select an empty or |
| 489 |
existing workspace folder, which is used for the output of all dense |
| 490 |
reconstruction results. The first step is to ``undistort`` the images, second to |
| 491 |
compute the depth and normal maps using ``stereo``, third to ``fuse`` the depth |
| 492 |
and normal maps into a point cloud, followed by a final, optional point cloud |
| 493 |
``meshing`` step. These steps are also available from the command-line as the |
| 494 |
``image_undistorter``, ``patch_match_stereo``, ``stereo_fusion``, and |
| 495 |
``poisson_mesher`` / ``delaunay_mesher`` commands, respectively. During the |
| 496 |
stereo reconstruction process, the display might |
| 497 |
freeze due to heavy compute load and, if your GPU does not have enough memory, |
| 498 |
the reconstruction process might crash ungracefully. Please refer to the FAQ |
| 499 |
(:ref:`freeze <faq-dense-timeout>` and :ref:`memory <faq-dense-memory>`) for |
| 500 |
information on how to avoid these problems. Note that the reconstructed normals |
| 501 |
of the point cloud cannot be visualized directly in COLMAP, but can be viewed in |
| 502 |
external tools such as Meshlab by enabling ``Render > Show Normal/Curvature``. Similarly, the reconstructed |
| 503 |
dense surface mesh model must be visualized with external software. |
| 504 |
|
| 505 |
In addition to the internal dense reconstruction functionality, COLMAP can |
| 506 |
export to several other dense reconstruction libraries, such as CMVS/PMVS |
| 507 |
[furukawa10]_ or CMP-MVS [jancosek11]_. Please choose ``Extras > Undistort images`` and select |
| 508 |
the appropriate format. The output folders contain the reconstruction and the |
| 509 |
undistorted images. In addition, the folders contain sample shell scripts to |
| 510 |
perform the dense reconstruction. To run PMVS2, execute the following command:: |
| 511 |
|
| 512 |
./path/to/pmvs2 /path/to/undistortion/folder/pmvs/ option-all |
| 513 |
|
| 514 |
where ``/path/to/undistortion/folder`` is the folder selected in the undistortion |
| 515 |
dialog. Make sure not to forget the trailing slash in |
| 516 |
``/path/to/undistortion/folder/pmvs/`` in the above command-line arguments. |
| 517 |
|
| 518 |
For large datasets, you probably want to first run CMVS to cluster the scene |
| 519 |
into more manageable parts and then run COLMAP or PMVS2. Please refer to the |
| 520 |
sample shell scripts in the undistortion output folder on how to run CMVS in |
| 521 |
combination with COLMAP or PMVS2. Moreover, there are a number of external |
| 522 |
libraries that support COLMAP's output: |
| 523 |
|
| 524 |
- `CMVS/PMVS <http://www.di.ens.fr/pmvs/>`_ [furukawa10]_ |
| 525 |
- `CMP-MVS <http://ptak.felk.cvut.cz/sfmservice/websfm.pl>`_ [jancosek11]_ |
| 526 |
- `Line3D++ <https://github.com/manhofer/Line3Dpp>`_ [hofer16]_. |
| 527 |
|
| 528 |
|
| 529 |
.. _database-management: |
| 530 |
|
| 531 |
Database Management |
| 532 |
------------------- |
| 533 |
|
| 534 |
You can review and manage the imported cameras, images, and feature matches in |
| 535 |
the database management tool. Choose ``Processing > Manage database``. In the |
| 536 |
opening dialog, you can see the list of imported images and cameras. You can |
| 537 |
view the features and matches for each image by clicking ``Show image`` and |
| 538 |
``Overlapping images``. Individual entries in the database tables can be |
| 539 |
modified by double-clicking specific cells. Note that any changes to the |
| 540 |
database are only effective after clicking ``Save``. |
| 541 |
|
| 542 |
To share intrinsic camera parameters between arbitrary groups of images, select |
| 543 |
one or more images, choose ``Set camera`` and set the ``camera_id``, |
| 544 |
which corresponds to the unique ``camera_id`` column in the cameras table. You can |
| 545 |
also add new cameras with specific parameters. By setting the |
| 546 |
``prior_focal_length`` flag to 0 or 1, you can give a hint whether the |
| 547 |
reconstruction algorithm should trust the focal length value. In case of a prior |
| 548 |
lab calibration, you should set this value to 1. Without prior knowledge about |
| 549 |
the focal length, it is recommended to set this value to ``1.25 * |
| 550 |
max(width_in_px, height_in_px)``. |
| 551 |
|
| 552 |
The database management tool has only limited functionality and, for full |
| 553 |
control over the data, you must directly modify the SQLite database (see |
| 554 |
:ref:`Database Format <database-format>`). By accessing the database directly, |
| 555 |
you can use COLMAP only for feature extraction and matching, or you can import |
| 556 |
your own features and matches and use COLMAP solely for its incremental |
| 557 |
reconstruction algorithm. |
| 558 |
|
| 559 |
|
| 560 |
.. _interface: |
| 561 |
|
| 562 |
Graphical and Command-line Interface |
| 563 |
------------------------------------ |
| 564 |
|
| 565 |
Most of COLMAP's features are accessible from both the graphical and the |
| 566 |
command-line interface, which are both embedded in the same executable. You can |
| 567 |
provide the options directly as command-line arguments or you can provide a |
| 568 |
``.ini`` project configuration file containing the options using the |
| 569 |
``--project_path path/to/project.ini`` argument. To start the GUI application, |
| 570 |
please execute ``colmap gui`` or directly specify a project configuration as |
| 571 |
``colmap gui --project_path path/to/project.ini`` to avoid tedious selection in |
| 572 |
the GUI. To list the different commands available from the command-line, execute |
| 573 |
``colmap help``. For example, to run feature extraction from the command-line, |
| 574 |
you must execute ``colmap feature_extractor``. The :ref:`graphical user |
| 575 |
interface <gui>` and :ref:`command-line interface <cli>` sections provide more |
| 576 |
details about the available commands. |
| 577 |
|
| 578 |
|
| 579 |
.. rubric:: Footnotes |
| 580 |
|
| 581 |
.. [#f1] VisualSfM's [wu13]_ projection model applies the distortion to the |
| 582 |
measurements and COLMAP to the projection, hence the exported NVM file is |
| 583 |
not fully compatible with VisualSfM. |