File: install.rst

package info (click to toggle)
colmap 3.12.6-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 11,928 kB
  • sloc: cpp: 101,944; ansic: 17,774; python: 4,958; sh: 366; makefile: 159
file content (332 lines) | stat: -rwxr-xr-x 10,432 bytes parent folder | download | duplicates (2)
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
.. _installation:

Installation
============

You can either download one of the pre-built binaries or build the source code
manually. Pre-built binaries and other resources can be downloaded from
https://demuc.de/colmap/.

An overview of system packages for Linux/Unix/BSD distributions are available at
https://repology.org/metapackage/colmap/versions. Note that the COLMAP packages
in the default repositories for Linux/Unix/BSD do not come with CUDA support,
which requires a manual build from source, as explained further below.

For Mac users, `Homebrew <https://brew.sh>`__ provides a formula for COLMAP with
pre-compiled binaries or the option to build from source. After installing
homebrew, installing COLMAP is as easy as running ``brew install colmap``.

COLMAP can be used as an independent application through the command-line or
graphical user interface. Alternatively, COLMAP is also built as a reusable
library, i.e., you can include and link COLMAP against your own C++ source code,
as described further below. Furthermore, you can use most of COLMAP's
functionality with :ref:`PyCOLMAP <pycolmap/index>` in Python.

------------------
Pre-built Binaries
------------------

Windows
-------

For convenience, the pre-built binaries for Windows contain both the graphical
and command-line interface executables. To start the COLMAP GUI, you can simply
double-click  the ``COLMAP.bat`` batch script or alternatively run it from the
Windows command shell or Powershell. The command-line interface is also
accessible through this batch script, which automatically sets the necessary
library paths. To list the available COLMAP commands, run ``COLMAP.bat -h`` in
the command shell ``cmd.exe`` or in Powershell. The first time you run COLMAP,
Windows defender may prompt you with a security warning, because the binaries
are not officially signed. The provided COLMAP binaries are automatically built
from GitHub Actions CI machines. If you do not trust them, you can build from
source as described below.

Docker
------

COLMAP provides a pre-built Docker image with CUDA support. For detailed
instructions on how to build and run COLMAP using Docker, please refer to the
`Docker documentation <https://github.com/colmap/colmap/tree/main/docker>`__.

-----------------
Build from Source
-----------------

COLMAP builds on all major platforms (Linux, Mac, Windows) with little effort.
First, checkout the latest source code::

    git clone https://github.com/colmap/colmap

Under Linux and Mac, it is generally recommended to follow the installation
instructions below, which use the respective system package managers to install
the required dependencies. Alternatively, the instructions for VCPKG can be used
to compile the required dependencies from scratch on more exotic systems with
limited system packages. The VCPKG approach is also the method of choice under
Windows, compute clusters, or if you do not have root access under Linux or Mac.


Debian/Ubuntu
-------------

*Recommended dependencies:* CUDA (at least version 7.X)

Dependencies from the default Ubuntu repositories::

    sudo apt-get install \
        git \
        cmake \
        ninja-build \
        build-essential \
        libboost-program-options-dev \
        libboost-graph-dev \
        libboost-system-dev \
        libeigen3-dev \
        libfreeimage-dev \
        libmetis-dev \
        libgoogle-glog-dev \
        libgtest-dev \
        libgmock-dev \
        libsqlite3-dev \
        libglew-dev \
        qt6-base-dev \
        libqt6opengl6-dev \
        libqt6openglwidgets6 \
        libcgal-dev \
        libceres-dev \
        libcurl4-openssl-dev \
        libssl-dev \
        libmkl-full-dev

Alternatively, you can also build against Qt 5 instead of Qt 6 using::

    qtbase5-dev libqt5opengl5-dev

To compile with **CUDA support**, also install Ubuntu's default CUDA package::

    sudo apt-get install -y \
        nvidia-cuda-toolkit \
        nvidia-cuda-toolkit-gcc

Or, manually install the latest CUDA from NVIDIA's homepage. During CMake
configuration, specify ``-DCMAKE_CUDA_ARCHITECTURES=native``, if you want to run
COLMAP only on your current machine (default), "all"/"all-major" to be able to
distribute to other machines, or a specific CUDA architecture like "75", etc.

Configure and compile COLMAP::

    git clone https://github.com/colmap/colmap.git
    cd colmap
    mkdir build
    cd build
    cmake .. -GNinja -DBLA_VENDOR=Intel10_64lp
    ninja
    sudo ninja install

Run COLMAP::

    colmap -h
    colmap gui

Under **Ubuntu 22.04**, there is a problem when compiling with Ubuntu's default
CUDA package and GCC, and you must compile against GCC 10::

    sudo apt-get install gcc-10 g++-10
    export CC=/usr/bin/gcc-10
    export CXX=/usr/bin/g++-10
    export CUDAHOSTCXX=/usr/bin/g++-10
    # ... and then run CMake against COLMAP's sources.

Notice that the ``BLA_VENDOR=Intel10_64lp`` option tells CMake to find Intel's MKL
implementation of BLAS. If you decide to compile against OpenBLAS instead of
MKL, you must install and select the OpenMP version under Debian/Ubuntu because
of `this issue <https://github.com/facebookresearch/faiss/wiki/Troubleshooting#surprising-faiss-openmp-and-openblas-interaction>`__.

Mac
---

Dependencies from `Homebrew <http://brew.sh/>`__::

    brew install \
        cmake \
        ninja \
        boost \
        eigen \
        freeimage \
        curl \
        libomp \
        metis \
        glog \
        googletest \
        ceres-solver \
        qt \
        glew \
        cgal \
        sqlite3
    brew link --force libomp

Configure and compile COLMAP::

    git clone https://github.com/colmap/colmap.git
    cd colmap
    mkdir build
    cd build
    cmake -GNinja
    ninja
    sudo ninja install

If you have Qt 5 installed on your system as well, you might have to temporarily
link your Qt 5 installation while configuring CMake::

    brew unlink qt && brew link --force qt
    cmake ...

Run COLMAP::

    colmap -h
    colmap gui


Windows
-------

*Recommended dependencies:* CUDA (at least version 7.X), Visual Studio 2019

On Windows, the recommended way is to build COLMAP using VCPKG::

    git clone https://github.com/microsoft/vcpkg
    cd vcpkg
    .\bootstrap-vcpkg.bat
    .\vcpkg install colmap[cuda,tests]:x64-windows

To compile CUDA for multiple compute architectures, please use::

    .\vcpkg install colmap[cuda-redist]:x64-windows

Please refer to the next section for more details.


VCPKG
-----

COLMAP ships as part of the VCPKG distribution. This enables to conveniently
build COLMAP and all of its dependencies from scratch under different platforms.
Note that VCPKG requires you to install CUDA manually in the standard way on
your platform. To compile COLMAP using VCPKG, you run::

    git clone https://github.com/microsoft/vcpkg
    cd vcpkg
    ./bootstrap-vcpkg.sh
    ./vcpkg install colmap:x64-linux

VCPKG ships with support for various other platforms (e.g., x64-osx,
x64-windows, etc.). To compile with CUDA support and to build all tests::

    ./vcpkg install colmap[cuda,tests]:x64-linux

The above commands will build the latest release version of COLMAP. To compile
the latest commit in the dev branch, you can use the following options::

    ./vcpkg install colmap:x64-linux --head

To modify the source code, you can further add ``--editable --no-downloads``.
Or, if you want to build from another folder and use the dependencies from
vcpkg, first run ``./vcpkg integrate install`` (under Windows use pwsh and
``./scripts/shell/enter_vs_dev_shell.ps1``) and then configure COLMAP as::

    cd path/to/colmap
    mkdir build
    cd build
    cmake .. -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
    cmake --build . --config release --target colmap --parallel 24


.. _installation-library:

-------
Library
-------

If you want to include and link COLMAP against your own library, the easiest way
is to use CMake as a build configuration tool. After configuring the COLMAP
build and running ``ninja/make install``, COLMAP automatically installs all
headers to ``${CMAKE_INSTALL_PREFIX}/include/colmap``, all libraries to
``${CMAKE_INSTALL_PREFIX}/lib/colmap``, and the CMake configuration to
``${CMAKE_INSTALL_PREFIX}/share/colmap``.

For example, compiling your own source code against COLMAP is as simple as
using the following ``CMakeLists.txt``::

    cmake_minimum_required(VERSION 3.10)

    project(SampleProject)

    find_package(colmap REQUIRED)
    # or to require a specific version: find_package(colmap 3.4 REQUIRED)

    add_executable(hello_world hello_world.cc)
    target_link_libraries(hello_world colmap::colmap)

with the source code ``hello_world.cc``::

    #include <cstdlib>
    #include <iostream>

    #include <colmap/controllers/option_manager.h>
    #include <colmap/util/string.h>

    int main(int argc, char** argv) {
        colmap::InitializeGlog(argv);

        std::string message;
        colmap::OptionManager options;
        options.AddRequiredOption("message", &message);
        options.Parse(argc, argv);

        std::cout << colmap::StringPrintf("Hello %s!\n", message.c_str());

        return EXIT_SUCCESS;
    }

Then compile and run your code as::

    mkdir build
    cd build
    export colmap_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap
    cmake .. -GNinja
    ninja
    ./hello_world --message "world"

The sources of this example are stored under ``doc/sample-project``.

----------------
AddressSanitizer
----------------

If you want to build COLMAP with address sanitizer flags enabled, you need to
use a recent compiler with ASan support. For example, you can manually install
a recent clang version on your Ubuntu machine and invoke CMake as follows::

    CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. \
        -DASAN_ENABLED=ON \
        -DTESTS_ENABLED=ON \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo

Note that it is generally useful to combine ASan with debug symbols to get
meaningful traces for reported issues.

-------------
Documentation
-------------

You need Python and Sphinx to build the HTML documentation::

    cd path/to/colmap/doc
    sudo apt-get install python
    pip install sphinx
    make html
    open _build/html/index.html

Alternatively, you can build the documentation as PDF, EPUB, etc.::

    make latexpdf
    open _build/pdf/COLMAP.pdf